#Van Oosten 2022 
#Electoral Studies 
#What shapes voter expectations of Muslim politicians' views on homosexuality: stereotyping or projection?
#https://doi.org/10.1016/j.electstud.2022.102553

setwd(" ")

library(haven)
library(patchwork)
library(cowplot)
library(gridGraphics)
library(GGally)
library(coefplot)
library(broom)
library(dplyr)
library(ellipsis)
library(tidyverse) 
library(tidyr)
library(magrittr)
library(stringr)
library(forcats)
library(ggplot2)
library(jtools)
library(sjPlot)
library(sjmisc)
library(sjlabelled)
library(miceadds)
library(vtable)
library(gt)
library(cregg)

FR <- haven::read_sav("DataFR_EMMAVID_vanOosten_etal_2024.sav")
DE <- haven::read_sav("DataDE_EMMAVID_vanOosten_etal_2024.sav")
NL <- haven::read_sav("DataNL_EMMAVID_vanOosten_etal_2024.sav")

#------------------------#
#--- Data preparation ---#
#------------------------#
#
##identification
##DE
#DE$Ger <- DE$V49001 
#DE$Tur <- DE$V49002 
#DE$FSU <- DE$V49005
#DE$Ukr <- DE$V49009 
##NL
#NL$Dut <- NL$V49008
#NL$Tur <- NL$V49010 
#NL$Mor <- NL$V49012 
#NL$Sur <- NL$V49013 
#NL$Hin <- NL$V49009 
#NL$Ara <- NL$V49002 
#NL$Ber <- NL$V49004 

#-------------------------#
#--- control variables ---#
#-------------------------#

#FR GEN
FR <- FR %>% mutate(Female = case_when(V640 == 1 ~ 0,
                                       V640 == 2 ~ 1))
#FR AGE
FR$AGE <- 2020 - FR$V650
FR$Age <- ((FR$AGE)/100)
#FR EDU
FR$EDU <- FR$V680
FR  <- mutate(FR, EDU = ifelse(is.na(EDU), 10, EDU))
FR <- FR %>% mutate(Education = case_when(FR$EDU == 1 ~ 0,
                                          FR$EDU == 2 ~ (1/8),
                                          FR$EDU == 3 ~ (2/8),
                                          FR$EDU == 4 ~ (3/8),
                                          FR$EDU == 5 ~ (4/8),
                                          FR$EDU == 6 ~ (5/8),
                                          FR$EDU == 7 ~ (6/8),
                                          FR$EDU == 8 ~ (7/8),
                                          FR$EDU == 9 ~ 1,
                                          FR$EDU == 10 ~ 0.5))

#DE GEN
DE <- DE %>% mutate(Female = case_when(V640 == 1 ~ 0,
                                       V640 == 2 ~ 1))
#DE AGE
DE$AGE <- 2020 - DE$V650
DE$Age <- ((DE$AGE)/100)
#DE EDU
DE$EDU <- DE$V680
DE  <- mutate(DE, EDU = ifelse(is.na(EDU), 10, EDU))
DE <- DE %>% mutate(Education = case_when(DE$EDU == 1 ~ 0,
                                          DE$EDU == 2 ~ (1/8),
                                          DE$EDU == 3 ~ (2/8),
                                          DE$EDU == 4 ~ (3/8),
                                          DE$EDU == 5 ~ (4/8),
                                          DE$EDU == 6 ~ (5/8),
                                          DE$EDU == 7 ~ (6/8),
                                          DE$EDU == 8 ~ (7/8),
                                          DE$EDU == 9 ~ 1,
                                          DE$EDU == 10 ~ 0.5))
#NL GEN
NL <- NL %>% mutate(Female = case_when(GSL == 1 ~ 0,
                                       GSL == 2 ~ 1))
#NL AGE
NL$Age <- ((NL$LFT)/100)
#NL EDU
NL <- NL %>% mutate(Education = case_when(NL$OPL == 1 ~ 0,
                                          NL$OPL == 2 ~ (1/6),
                                          NL$OPL == 3 ~ (2/6),
                                          NL$OPL == 4 ~ (3/6),
                                          NL$OPL == 5 ~ (4/6),
                                          NL$OPL == 6 ~ (5/6),
                                          NL$OPL == 7 ~ 1,
                                          NL$OPL == 8 ~ 0.5))
FR$AGE2 <- (FR$Age*FR$Age)
DE$AGE2 <- (DE$Age*DE$Age)
NL$AGE2 <- (NL$Age*NL$Age)

#top down, categorized
FR <- FR %>% mutate(catraceFR = case_when(V50030 == 1 & V50040 == 1 ~ "Turkey",
                                          V50030 == 2 & V50040 == 2 ~ "North-Africa",
                                          V50030 == 3 & V50040 == 3 ~ "Sub-Saharan Africa",
                                          V50030 == 4 & V50040 == 4 ~ "France",
                                          V50030 == 5 & V50040 == 5 ~ "Other",
                                          
                                          V50030 == 1 & V50040 == 4 ~ "Turkey",
                                          V50030 == 4 & V50040 == 1 ~ "Turkey",
                                          V50030 == 1 & V50040 == 5 ~ "Turkey",
                                          V50030 == 5 & V50040 == 1 ~ "Turkey",
                                          
                                          V50030 == 2 & V50040 == 4 ~ "North-Africa",
                                          V50030 == 4 & V50040 == 2 ~ "North-Africa",
                                          V50030 == 2 & V50040 == 5 ~ "North-Africa",
                                          V50030 == 5 & V50040 == 2 ~ "North-Africa",
                                          
                                          V50030 == 3 & V50040 == 4 ~ "Sub-Saharan Africa",
                                          V50030 == 4 & V50040 == 3 ~ "Sub-Saharan Africa",
                                          V50030 == 3 & V50040 == 5 ~ "Sub-Saharan Africa",
                                          V50030 == 5 & V50040 == 3 ~ "Sub-Saharan Africa",
                                          
                                          V50030 == 1 & V50040 == 2 ~ "Turkey/North-Africa",
                                          V50030 == 2 & V50040 == 1 ~ "North-Africa/Turkey",
                                          V50030 == 1 & V50040 == 3 ~ "Turkey/Sub-Saharan Africa",
                                          V50030 == 3 & V50040 == 1 ~ "Sub-Saharan Africa/Turkey",
                                          V50030 == 2 & V50040 == 3 ~ "North-Africa/Sub-Saharan Africa",
                                          V50030 == 3 & V50040 == 2 ~ "Sub-Saharan Africa/North-Africa",
                                          
                                          V50030 == 4 & V50040 == 5 ~ "France/Other",
                                          V50030 == 5 & V50040 == 4 ~ "Other/France"))
FR <- FR %>% mutate(catrace = case_when(V50030 == 1 & V50040 == 1 ~ "Turkey",
                                           V50030 == 2 & V50040 == 2 ~ "North-Africa",
                                           V50030 == 3 & V50040 == 3 ~ "Sub-Saharan Africa",
                                           V50030 == 4 & V50040 == 4 ~ "France",
                                           V50030 == 5 & V50040 == 5 ~ "Other",
                                           
                                           V50030 == 1 & V50040 == 4 ~ "Turkey",
                                           V50030 == 4 & V50040 == 1 ~ "Turkey",
                                           V50030 == 1 & V50040 == 5 ~ "Turkey",
                                           V50030 == 5 & V50040 == 1 ~ "Turkey",
                                           
                                           V50030 == 2 & V50040 == 4 ~ "North-Africa",
                                           V50030 == 4 & V50040 == 2 ~ "North-Africa",
                                           V50030 == 2 & V50040 == 5 ~ "North-Africa",
                                           V50030 == 5 & V50040 == 2 ~ "North-Africa",
                                           
                                           V50030 == 3 & V50040 == 4 ~ "Sub-Saharan Africa",
                                           V50030 == 4 & V50040 == 3 ~ "Sub-Saharan Africa",
                                           V50030 == 3 & V50040 == 5 ~ "Sub-Saharan Africa",
                                           V50030 == 5 & V50040 == 3 ~ "Sub-Saharan Africa",
                                           
                                           V50030 == 1 & V50040 == 2 ~ "Turkey",
                                           V50030 == 2 & V50040 == 1 ~ "North-Africa",
                                           V50030 == 1 & V50040 == 3 ~ "Turkey",
                                           V50030 == 3 & V50040 == 1 ~ "Sub-Saharan Africa",
                                           V50030 == 2 & V50040 == 3 ~ "North-Africa",
                                           V50030 == 3 & V50040 == 2 ~ "Sub-Saharan Africa",
                                           
                                           V50030 == 4 & V50040 == 5 ~ "France",
                                           V50030 == 5 & V50040 == 4 ~ "France"))
DE <- DE %>% mutate(catraceDE = case_when(V50030 == 1 & V50040 == 1 ~ "Turkey",
                                          V50030 == 2 & V50040 == 2 ~ "FSU",
                                          V50030 == 3 & V50040 == 3 ~ "German",
                                          V50030 == 4 & V50040 == 4 ~ "Other",
                                          
                                          V50030 == 1 & V50040 == 3 ~ "Turkey",
                                          V50030 == 3 & V50040 == 1 ~ "Turkey",
                                          V50030 == 1 & V50040 == 4 ~ "Turkey",
                                          V50030 == 4 & V50040 == 1 ~ "Turkey",
                                          
                                          V50030 == 2 & V50040 == 3 ~ "FSU",
                                          V50030 == 3 & V50040 == 2 ~ "FSU",
                                          V50030 == 2 & V50040 == 4 ~ "FSU",
                                          V50030 == 4 & V50040 == 2 ~ "FSU",
                                          
                                          V50030 == 1 & V50040 == 2 ~ "Turkey/FSU",
                                          V50030 == 2 & V50040 == 1 ~ "FSU/Turkey",
                                          V50030 == 3 & V50040 == 4 ~ "German/Other",
                                          V50030 == 4 & V50040 == 3 ~ "Other/German"))
DE <- DE %>% mutate(catraceDEb = case_when(V50030 == 1 & V50040 == 1 ~ "Turkey",
                                           V50030 == 2 & V50040 == 2 ~ "FSU",
                                           V50030 == 3 & V50040 == 3 ~ "German",
                                           V50030 == 4 & V50040 == 4 ~ "Other",
                                           
                                           V50030 == 1 & V50040 == 3 ~ "Turkey",
                                           V50030 == 3 & V50040 == 1 ~ "Turkey",
                                           V50030 == 1 & V50040 == 4 ~ "Turkey",
                                           V50030 == 4 & V50040 == 1 ~ "Turkey",
                                           
                                           V50030 == 2 & V50040 == 3 ~ "FSU",
                                           V50030 == 3 & V50040 == 2 ~ "FSU",
                                           V50030 == 2 & V50040 == 4 ~ "FSU",
                                           V50030 == 4 & V50040 == 2 ~ "FSU",
                                           
                                           V50030 == 1 & V50040 == 2 ~ "Turkey",
                                           V50030 == 2 & V50040 == 1 ~ "FSU",
                                           V50030 == 3 & V50040 == 4 ~ "German",
                                           V50030 == 4 & V50040 == 3 ~ "German"))
NL <- NL %>% mutate(catraceNL = case_when(V50030 == 1 & V50040 == 1 ~ "Turkey",
                                          V50030 == 2 & V50040 == 2 ~ "Morocco",
                                          V50030 == 3 & V50040 == 3 ~ "Surinam",
                                          V50030 == 4 & V50040 == 4 ~ "Dutch",
                                          V50030 == 5 & V50040 == 5 ~ "Other",
                                          
                                          V50030 == 1 & V50040 == 4 ~ "Turkey",
                                          V50030 == 4 & V50040 == 1 ~ "Turkey",
                                          V50030 == 1 & V50040 == 5 ~ "Turkey",
                                          V50030 == 5 & V50040 == 1 ~ "Turkey",
                                          
                                          V50030 == 2 & V50040 == 4 ~ "Morocco",
                                          V50030 == 4 & V50040 == 2 ~ "Morocco",
                                          V50030 == 2 & V50040 == 5 ~ "Morocco",
                                          V50030 == 5 & V50040 == 2 ~ "Morocco",
                                          
                                          V50030 == 3 & V50040 == 4 ~ "Surinam",
                                          V50030 == 4 & V50040 == 3 ~ "Surinam",
                                          V50030 == 3 & V50040 == 5 ~ "Surinam",
                                          V50030 == 5 & V50040 == 3 ~ "Surinam",
                                          
                                          V50030 == 1 & V50040 == 2 ~ "Turkey/Morocco",
                                          V50030 == 2 & V50040 == 1 ~ "Morocco/Turkey",
                                          V50030 == 1 & V50040 == 3 ~ "Turkey/Surinam",
                                          V50030 == 3 & V50040 == 1 ~ "Surinam/Turkey",
                                          V50030 == 2 & V50040 == 3 ~ "Morocco/Surinam",
                                          V50030 == 3 & V50040 == 2 ~ "Surinam/Morocco",
                                          
                                          V50030 == 4 & V50040 == 5 ~ "Dutch/Other",
                                          V50030 == 5 & V50040 == 4 ~ "Other/Dutch"))
NL <- NL %>% mutate(catraceNLb = case_when(V50030 == 1 & V50040 == 1 ~ "Turkey",
                                           V50030 == 2 & V50040 == 2 ~ "Morocco",
                                           V50030 == 3 & V50040 == 3 ~ "Surinam",
                                           V50030 == 4 & V50040 == 4 ~ "Dutch",
                                           V50030 == 5 & V50040 == 5 ~ "Other",
                                           
                                           V50030 == 1 & V50040 == 4 ~ "Turkey",
                                           V50030 == 4 & V50040 == 1 ~ "Turkey",
                                           V50030 == 1 & V50040 == 5 ~ "Turkey",
                                           V50030 == 5 & V50040 == 1 ~ "Turkey",
                                           
                                           V50030 == 2 & V50040 == 4 ~ "Morocco",
                                           V50030 == 4 & V50040 == 2 ~ "Morocco",
                                           V50030 == 2 & V50040 == 5 ~ "Morocco",
                                           V50030 == 5 & V50040 == 2 ~ "Morocco",
                                           
                                           V50030 == 3 & V50040 == 4 ~ "Surinam",
                                           V50030 == 4 & V50040 == 3 ~ "Surinam",
                                           V50030 == 3 & V50040 == 5 ~ "Surinam",
                                           V50030 == 5 & V50040 == 3 ~ "Surinam",
                                           
                                           V50030 == 1 & V50040 == 2 ~ "Turkey",
                                           V50030 == 2 & V50040 == 1 ~ "Morocco",
                                           V50030 == 1 & V50040 == 3 ~ "Turkey",
                                           V50030 == 3 & V50040 == 1 ~ "Surinam",
                                           V50030 == 2 & V50040 == 3 ~ "Morocco",
                                           V50030 == 3 & V50040 == 2 ~ "Surinam",
                                           
                                           V50030 == 4 & V50040 == 5 ~ "Dutch",
                                           V50030 == 5 & V50040 == 4 ~ "Dutch"))

#--------------------------------#
#--- self-identified religion ---#
#--------------------------------#

#FR
FR <- FR %>% mutate(binidrel2 = case_when(V580 == 2 ~ "Non-religious",
                                          V590 == 3 ~ "Other",
                                          V590 == 4 ~ "Other",
                                          V590 == 5 ~ "Other",
                                          V590 == 6 ~ "Other",
                                          V600 == 1 ~ "Muslim",
                                          V600 == 2 ~ "Muslim",
                                          V600 == 3 ~ "Muslim",
                                          V600 == 4 ~ "Muslim",
                                          V610 == 1 ~ "Christian",
                                          V610 == 2 ~ "Christian",
                                          V610 == 3 ~ "Christian"))
FR <- FR %>% mutate(relMus = case_when(V580 == 2 ~ 0,
                                         V590 == 3 ~ 0,
                                         V590 == 4 ~ 0,
                                         V590 == 5 ~ 0,
                                         V590 == 6 ~ 0,
                                         V600 == 1 ~ 1,
                                         V600 == 2 ~ 1,
                                         V600 == 3 ~ 1,
                                         V600 == 4 ~ 1,
                                         V610 == 1 ~ 0,
                                         V610 == 3 ~ 0))
FR <- FR %>% mutate(relChr = case_when(V580 == 2 ~ 0,
                                         V590 == 3 ~ 0,
                                         V590 == 4 ~ 0,
                                         V590 == 5 ~ 0,
                                         V590 == 6 ~ 0,
                                         V600 == 1 ~ 0,
                                         V600 == 2 ~ 0,
                                         V600 == 3 ~ 0,
                                         V600 == 4 ~ 0,
                                         V610 == 1 ~ 1,
                                         V610 == 2 ~ 1,
                                         V610 == 3 ~ 1))
FR <- FR %>% mutate(relOth = case_when(V580 == 2 ~ 0,
                                         V590 == 3 ~ 1,
                                         V590 == 4 ~ 1,
                                         V590 == 5 ~ 1,
                                         V590 == 6 ~ 1,
                                         V600 == 1 ~ 0,
                                         V600 == 2 ~ 0,
                                         V600 == 3 ~ 0,
                                         V600 == 4 ~ 0,
                                         V610 == 1 ~ 0,
                                         V610 == 2 ~ 0,
                                         V610 == 3 ~ 0))
FR <- FR %>% mutate(relNon = case_when(V580 == 2 ~ 1,
                                         V590 == 3 ~ 0,
                                         V590 == 4 ~ 0,
                                         V590 == 5 ~ 0,
                                         V590 == 6 ~ 0,
                                         V600 == 1 ~ 0,
                                         V600 == 2 ~ 0,
                                         V600 == 3 ~ 0,
                                         V600 == 4 ~ 0,
                                         V610 == 1 ~ 0,
                                         V610 == 2 ~ 0,
                                         V610 == 3 ~ 0))
#DE
DE <- DE %>% mutate(binidrel2 = case_when(V580 == 2 ~ "Non-religious",
                                          V590 == 3 ~ "Other",
                                          V590 == 4 ~ "Other",
                                          V590 == 5 ~ "Other",
                                          V590 == 6 ~ "Other",
                                          V600 == 1 ~ "Muslim",
                                          V600 == 2 ~ "Muslim",
                                          V600 == 3 ~ "Muslim",
                                          V600 == 4 ~ "Muslim",
                                          V610 == 1 ~ "Christian",
                                          V610 == 2 ~ "Christian",
                                          V610 == 3 ~ "Christian"))
DE <- DE %>% mutate(relMus = case_when(V580 == 2 ~ 0,
                                         V590 == 3 ~ 0,
                                         V590 == 4 ~ 0,
                                         V590 == 5 ~ 0,
                                         V590 == 6 ~ 0,
                                         V600 == 1 ~ 1,
                                         V600 == 2 ~ 1,
                                         V600 == 3 ~ 1,
                                         V600 == 4 ~ 1,
                                         V610 == 1 ~ 0,
                                         V610 == 2 ~ 0,
                                         V610 == 3 ~ 0))
DE <- DE %>% mutate(relChr = case_when(V580 == 2 ~ 0,
                                         V590 == 3 ~ 0,
                                         V590 == 4 ~ 0,
                                         V590 == 5 ~ 0,
                                         V590 == 6 ~ 0,
                                         V600 == 1 ~ 0,
                                         V600 == 2 ~ 0,
                                         V600 == 3 ~ 0,
                                         V600 == 4 ~ 0,
                                         V610 == 1 ~ 1,
                                         V610 == 2 ~ 1,
                                         V610 == 3 ~ 1))
DE <- DE %>% mutate(relOth = case_when(V580 == 2 ~ 0,
                                         V590 == 3 ~ 1,
                                         V590 == 4 ~ 1,
                                         V590 == 5 ~ 1,
                                         V590 == 6 ~ 1,
                                         V600 == 1 ~ 0,
                                         V600 == 2 ~ 0,
                                         V600 == 3 ~ 0,
                                         V600 == 4 ~ 0,
                                         V610 == 1 ~ 0,
                                         V610 == 2 ~ 0,
                                         V610 == 3 ~ 0))
DE <- DE %>% mutate(relNon = case_when(V580 == 2 ~ 1,
                                         V590 == 3 ~ 0,
                                         V590 == 4 ~ 0,
                                         V590 == 5 ~ 0,
                                         V590 == 6 ~ 0,
                                         V600 == 1 ~ 0,
                                         V600 == 2 ~ 0,
                                         V600 == 3 ~ 0,
                                         V600 == 4 ~ 0,
                                         V610 == 1 ~ 0,
                                         V610 == 2 ~ 0,
                                         V610 == 3 ~ 0))
#NL
NL <- NL %>% mutate(binidrel2 = case_when(V580 == 2 ~ "Non-religious",
                                          V590 == 3 ~ "Other",
                                          V590 == 4 ~ "Other",
                                          V590 == 5 ~ "Other",
                                          V590 == 6 ~ "Other",
                                          V600 == 1 ~ "Muslim",
                                          V600 == 2 ~ "Muslim",
                                          V600 == 3 ~ "Muslim",
                                          V600 == 4 ~ "Muslim",
                                          V610 == 1 ~ "Christian",
                                          V610 == 2 ~ "Christian",
                                          V610 == 3 ~ "Christian"))
NL <- NL %>% mutate(relMus = case_when(V580 == 2 ~ 0,
                                         V590 == 3 ~ 0,
                                         V590 == 4 ~ 0,
                                         V590 == 5 ~ 0,
                                         V590 == 6 ~ 0,
                                         V600 == 1 ~ 1,
                                         V600 == 2 ~ 1,
                                         V600 == 3 ~ 1,
                                         V600 == 4 ~ 1,
                                         V610 == 1 ~ 0,
                                         V610 == 2 ~ 0,
                                         V610 == 3 ~ 0))
NL <- NL %>% mutate(relChr = case_when(V580 == 2 ~ 0,
                                         V590 == 3 ~ 0,
                                         V590 == 4 ~ 0,
                                         V590 == 5 ~ 0,
                                         V590 == 6 ~ 0,
                                         V600 == 1 ~ 0,
                                         V600 == 2 ~ 0,
                                         V600 == 3 ~ 0,
                                         V600 == 4 ~ 0,
                                         V610 == 1 ~ 1,
                                         V610 == 2 ~ 1,
                                         V610 == 3 ~ 1))
NL <- NL %>% mutate(relOth = case_when(V580 == 2 ~ 0,
                                         V590 == 3 ~ 1,
                                         V590 == 4 ~ 1,
                                         V590 == 5 ~ 1,
                                         V590 == 6 ~ 1,
                                         V600 == 1 ~ 0,
                                         V600 == 2 ~ 0,
                                         V600 == 3 ~ 0,
                                         V600 == 4 ~ 0,
                                         V610 == 1 ~ 0,
                                         V610 == 2 ~ 0,
                                         V610 == 3 ~ 0))
NL <- NL %>% mutate(relNon = case_when(V580 == 2 ~ 1,
                                         V590 == 3 ~ 0,
                                         V590 == 4 ~ 0,
                                         V590 == 5 ~ 0,
                                         V590 == 6 ~ 0,
                                         V600 == 1 ~ 0,
                                         V600 == 2 ~ 0,
                                         V600 == 3 ~ 0,
                                         V600 == 4 ~ 0,
                                         V610 == 1 ~ 0,
                                         V610 == 2 ~ 0,
                                         V610 == 3 ~ 0))

#------------------------#
#--- policy positions ---#
#------------------------#
#equal.pay.by.law
FR <- FR %>% mutate(equal.pay.by.law = case_when(V160_13 == 1 ~ 0.0,
                                                 V160_13 == 2 ~ 0.1,
                                                 V160_13 == 3 ~ 0.2,
                                                 V160_13 == 4 ~ 0.3,
                                                 V160_13 == 5 ~ 0.4,
                                                 V160_13 == 6 ~ 0.5,
                                                 V160_13 == 7 ~ 0.6,
                                                 V160_13 == 8 ~ 0.7,
                                                 V160_13 == 9 ~ 0.8,
                                                 V160_13 == 10 ~ 0.9,
                                                 V160_13 == 11 ~ 1,
                                                 V80_14 == 1 ~ 1,
                                                 V80_14 == 2 ~ 0.9,
                                                 V80_14 == 3 ~ 0.8,
                                                 V80_14 == 4 ~ 0.7,
                                                 V80_14 == 5 ~ 0.6,
                                                 V80_14 == 6 ~ 0.5,
                                                 V80_14 == 7 ~ 0.4,
                                                 V80_14 == 8 ~ 0.3,
                                                 V80_14 == 9 ~ 0.2,
                                                 V80_14 == 10 ~ 0.1,
                                                 V80_14 == 11 ~ 0.0))
DE <- DE %>% mutate(equal.pay.by.law = case_when(V160_13 == 1 ~ 0.0,
                                                 V160_13 == 2 ~ 0.1,
                                                 V160_13 == 3 ~ 0.2,
                                                 V160_13 == 4 ~ 0.3,
                                                 V160_13 == 5 ~ 0.4,
                                                 V160_13 == 6 ~ 0.5,
                                                 V160_13 == 7 ~ 0.6,
                                                 V160_13 == 8 ~ 0.7,
                                                 V160_13 == 9 ~ 0.8,
                                                 V160_13 == 10 ~ 0.9,
                                                 V160_13 == 11 ~ 1,
                                                 V80_14 == 1 ~ 1,
                                                 V80_14 == 2 ~ 0.9,
                                                 V80_14 == 3 ~ 0.8,
                                                 V80_14 == 4 ~ 0.7,
                                                 V80_14 == 5 ~ 0.6,
                                                 V80_14 == 6 ~ 0.5,
                                                 V80_14 == 7 ~ 0.4,
                                                 V80_14 == 8 ~ 0.3,
                                                 V80_14 == 9 ~ 0.2,
                                                 V80_14 == 10 ~ 0.1,
                                                 V80_14 == 11 ~ 0.0))
NL <- NL %>% mutate(equal.pay.by.law = case_when(V160_13 == 1 ~ 0.0,
                                                 V160_13 == 2 ~ 0.1,
                                                 V160_13 == 3 ~ 0.2,
                                                 V160_13 == 4 ~ 0.3,
                                                 V160_13 == 5 ~ 0.4,
                                                 V160_13 == 6 ~ 0.5,
                                                 V160_13 == 7 ~ 0.6,
                                                 V160_13 == 8 ~ 0.7,
                                                 V160_13 == 9 ~ 0.8,
                                                 V160_13 == 10 ~ 0.9,
                                                 V160_13 == 11 ~ 1,
                                                 V80_14 == 1 ~ 1,
                                                 V80_14 == 2 ~ 0.9,
                                                 V80_14 == 3 ~ 0.8,
                                                 V80_14 == 4 ~ 0.7,
                                                 V80_14 == 5 ~ 0.6,
                                                 V80_14 == 6 ~ 0.5,
                                                 V80_14 == 7 ~ 0.4,
                                                 V80_14 == 8 ~ 0.3,
                                                 V80_14 == 9 ~ 0.2,
                                                 V80_14 == 10 ~ 0.1,
                                                 V80_14 == 11 ~ 0.0))

#homoco.may.adopt
FR <- FR %>% mutate(homoco.may.adopt = case_when(V80_16 == 1 ~ 0.0,
                                                 V80_16 == 2 ~ 0.1,
                                                 V80_16 == 3 ~ 0.2,
                                                 V80_16 == 4 ~ 0.3,
                                                 V80_16 == 5 ~ 0.4,
                                                 V80_16 == 6 ~ 0.5,
                                                 V80_16 == 7 ~ 0.6,
                                                 V80_16 == 8 ~ 0.7,
                                                 V80_16 == 9 ~ 0.8,
                                                 V80_16 == 10 ~ 0.9,
                                                 V80_16 == 11 ~ 1,
                                                 V160_15 == 1 ~ 1,
                                                 V160_15 == 2 ~ 0.9,
                                                 V160_15 == 3 ~ 0.8,
                                                 V160_15 == 4 ~ 0.7,
                                                 V160_15 == 5 ~ 0.6,
                                                 V160_15 == 6 ~ 0.5,
                                                 V160_15 == 7 ~ 0.4,
                                                 V160_15 == 8 ~ 0.3,
                                                 V160_15 == 9 ~ 0.2,
                                                 V160_15 == 10 ~ 0.1,
                                                 V160_15 == 11 ~ 0.0))
DE <- DE %>% mutate(homoco.may.adopt = case_when(V80_16 == 1 ~ 0.0,
                                                 V80_16 == 2 ~ 0.1,
                                                 V80_16 == 3 ~ 0.2,
                                                 V80_16 == 4 ~ 0.3,
                                                 V80_16 == 5 ~ 0.4,
                                                 V80_16 == 6 ~ 0.5,
                                                 V80_16 == 7 ~ 0.6,
                                                 V80_16 == 8 ~ 0.7,
                                                 V80_16 == 9 ~ 0.8,
                                                 V80_16 == 10 ~ 0.9,
                                                 V80_16 == 11 ~ 1,
                                                 V160_15 == 1 ~ 1,
                                                 V160_15 == 2 ~ 0.9,
                                                 V160_15 == 3 ~ 0.8,
                                                 V160_15 == 4 ~ 0.7,
                                                 V160_15 == 5 ~ 0.6,
                                                 V160_15 == 6 ~ 0.5,
                                                 V160_15 == 7 ~ 0.4,
                                                 V160_15 == 8 ~ 0.3,
                                                 V160_15 == 9 ~ 0.2,
                                                 V160_15 == 10 ~ 0.1,
                                                 V160_15 == 11 ~ 0.0))
NL <- NL %>% mutate(homoco.may.adopt = case_when(V80_16 == 1 ~ 0.0,
                                                 V80_16 == 2 ~ 0.1,
                                                 V80_16 == 3 ~ 0.2,
                                                 V80_16 == 4 ~ 0.3,
                                                 V80_16 == 5 ~ 0.4,
                                                 V80_16 == 6 ~ 0.5,
                                                 V80_16 == 7 ~ 0.6,
                                                 V80_16 == 8 ~ 0.7,
                                                 V80_16 == 9 ~ 0.8,
                                                 V80_16 == 10 ~ 0.9,
                                                 V80_16 == 11 ~ 1,
                                                 V160_15 == 1 ~ 1,
                                                 V160_15 == 2 ~ 0.9,
                                                 V160_15 == 3 ~ 0.8,
                                                 V160_15 == 4 ~ 0.7,
                                                 V160_15 == 5 ~ 0.6,
                                                 V160_15 == 6 ~ 0.5,
                                                 V160_15 == 7 ~ 0.4,
                                                 V160_15 == 8 ~ 0.3,
                                                 V160_15 == 9 ~ 0.2,
                                                 V160_15 == 10 ~ 0.1,
                                                 V160_15 == 11 ~ 0.0))

#---------------------------------#
#--- Expectations: politicians ---#
#---------------------------------#

#FR
#equal.pay.by.law
FR <- FR %>% mutate(equal.pay.by.law.exp.01_1 = case_when(V337_1 == 1 ~ 1,
                                                          V337_1 == 2 ~ 0))
FR <- FR %>% mutate(equal.pay.by.law.exp.01_2 = case_when(V337_2 == 1 ~ 1,
                                                          V337_2 == 2 ~ 0))
FR <- FR %>% mutate(equal.pay.by.law.exp.se_1 = case_when(V337_1 == 1 ~ 1,
                                                          V337_1 == 2 ~ 1,
                                                          V337_1 == 3 ~ 1))
FR <- FR %>% mutate(equal.pay.by.law.exp.se_2 = case_when(V337_2 == 1 ~ 1,
                                                          V337_2 == 2 ~ 1,
                                                          V337_2 == 3 ~ 1))
FR <- FR %>% mutate(equal.pay.by.law.exp.le_1 = case_when(V337_1 == 1 ~ 1,
                                                          V337_1 == 2 ~ 0,
                                                          V337_1 == 3 ~ 0))
FR <- FR %>% mutate(equal.pay.by.law.exp.le_2 = case_when(V337_2 == 1 ~ 1,
                                                          V337_2 == 2 ~ 0,
                                                          V337_2 == 3 ~ 0))
FR <- FR %>% mutate(equal.pay.by.law.exp.ri_1 = case_when(V337_1 == 1 ~ 0,
                                                          V337_1 == 2 ~ 1,
                                                          V337_1 == 3 ~ 0))
FR <- FR %>% mutate(equal.pay.by.law.exp.ri_2 = case_when(V337_2 == 1 ~ 0,
                                                          V337_2 == 2 ~ 1,
                                                          V337_2 == 3 ~ 0))
FR <- FR %>% mutate(equal.pay.by.law.exp.dk_1 = case_when(V337_1 == 1 ~ 0,
                                                          V337_1 == 2 ~ 0,
                                                          V337_1 == 3 ~ 1))
FR <- FR %>% mutate(equal.pay.by.law.exp.dk_2 = case_when(V337_2 == 1 ~ 0,
                                                          V337_2 == 2 ~ 0,
                                                          V337_2 == 3 ~ 1))
#homoco.may.adopt
FR <- FR %>% mutate(homoco.may.adopt.exp.01_1 = case_when(V338_1 == 2 ~ 1,
                                                          V338_1 == 1 ~ 0))
FR <- FR %>% mutate(homoco.may.adopt.exp.01_2 = case_when(V338_2 == 2 ~ 1,
                                                          V338_2 == 1 ~ 0))
FR <- FR %>% mutate(homoco.may.adopt.exp.se_1 = case_when(V338_1 == 1 ~ 1,
                                                          V338_1 == 2 ~ 1,
                                                          V338_1 == 3 ~ 1))
FR <- FR %>% mutate(homoco.may.adopt.exp.se_2 = case_when(V338_2 == 1 ~ 1,
                                                          V338_2 == 2 ~ 1,
                                                          V338_2 == 3 ~ 1))
FR <- FR %>% mutate(homoco.may.adopt.exp.ri_1 = case_when(V338_1 == 1 ~ 1,
                                                          V338_1 == 2 ~ 0,
                                                          V338_1 == 3 ~ 0))
FR <- FR %>% mutate(homoco.may.adopt.exp.ri_2 = case_when(V338_2 == 1 ~ 1,
                                                          V338_2 == 2 ~ 0,
                                                          V338_2 == 3 ~ 0))
FR <- FR %>% mutate(homoco.may.adopt.exp.le_1 = case_when(V338_1 == 1 ~ 0,
                                                          V338_1 == 2 ~ 1,
                                                          V338_1 == 3 ~ 0))
FR <- FR %>% mutate(homoco.may.adopt.exp.le_2 = case_when(V338_2 == 1 ~ 0,
                                                          V338_2 == 2 ~ 1,
                                                          V338_2 == 3 ~ 0))
FR <- FR %>% mutate(homoco.may.adopt.exp.dk_1 = case_when(V338_1 == 1 ~ 0,
                                                          V338_1 == 2 ~ 0,
                                                          V338_1 == 3 ~ 1))
FR <- FR %>% mutate(homoco.may.adopt.exp.dk_2 = case_when(V338_2 == 1 ~ 0,
                                                          V338_2 == 2 ~ 0,
                                                          V338_2 == 3 ~ 1))

#DE
#equal.pay.by.law
DE <- DE %>% mutate(equal.pay.by.law.exp.01_1 = case_when(V337_1 == 1 ~ 1,
                                                          V337_1 == 2 ~ 0))
DE <- DE %>% mutate(equal.pay.by.law.exp.01_2 = case_when(V337_2 == 1 ~ 1,
                                                          V337_2 == 2 ~ 0))
DE <- DE %>% mutate(equal.pay.by.law.exp.se_1 = case_when(V337_1 == 1 ~ 1,
                                                          V337_1 == 2 ~ 1,
                                                          V337_1 == 3 ~ 1))
DE <- DE %>% mutate(equal.pay.by.law.exp.se_2 = case_when(V337_2 == 1 ~ 1,
                                                          V337_2 == 2 ~ 1,
                                                          V337_2 == 3 ~ 1))
DE <- DE %>% mutate(equal.pay.by.law.exp.le_1 = case_when(V337_1 == 1 ~ 1,
                                                          V337_1 == 2 ~ 0,
                                                          V337_1 == 3 ~ 0))
DE <- DE %>% mutate(equal.pay.by.law.exp.le_2 = case_when(V337_2 == 1 ~ 1,
                                                          V337_2 == 2 ~ 0,
                                                          V337_2 == 3 ~ 0))
DE <- DE %>% mutate(equal.pay.by.law.exp.ri_1 = case_when(V337_1 == 1 ~ 0,
                                                          V337_1 == 2 ~ 1,
                                                          V337_1 == 3 ~ 0))
DE <- DE %>% mutate(equal.pay.by.law.exp.ri_2 = case_when(V337_2 == 1 ~ 0,
                                                          V337_2 == 2 ~ 1,
                                                          V337_2 == 3 ~ 0))
DE <- DE %>% mutate(equal.pay.by.law.exp.dk_1 = case_when(V337_1 == 1 ~ 0,
                                                          V337_1 == 2 ~ 0,
                                                          V337_1 == 3 ~ 1))
DE <- DE %>% mutate(equal.pay.by.law.exp.dk_2 = case_when(V337_2 == 1 ~ 0,
                                                          V337_2 == 2 ~ 0,
                                                          V337_2 == 3 ~ 1))
#homoco.may.adopt
DE <- DE %>% mutate(homoco.may.adopt.exp.01_1 = case_when(V338_1 == 2 ~ 1,
                                                          V338_1 == 1 ~ 0))
DE <- DE %>% mutate(homoco.may.adopt.exp.01_2 = case_when(V338_2 == 2 ~ 1,
                                                          V338_2 == 1 ~ 0))
DE <- DE %>% mutate(homoco.may.adopt.exp.se_1 = case_when(V338_1 == 1 ~ 1,
                                                          V338_1 == 2 ~ 1,
                                                          V338_1 == 3 ~ 1))
DE <- DE %>% mutate(homoco.may.adopt.exp.se_2 = case_when(V338_2 == 1 ~ 1,
                                                          V338_2 == 2 ~ 1,
                                                          V338_2 == 3 ~ 1))
DE <- DE %>% mutate(homoco.may.adopt.exp.ri_1 = case_when(V338_1 == 1 ~ 1,
                                                          V338_1 == 2 ~ 0,
                                                          V338_1 == 3 ~ 0))
DE <- DE %>% mutate(homoco.may.adopt.exp.ri_2 = case_when(V338_2 == 1 ~ 1,
                                                          V338_2 == 2 ~ 0,
                                                          V338_2 == 3 ~ 0))
DE <- DE %>% mutate(homoco.may.adopt.exp.le_1 = case_when(V338_1 == 1 ~ 0,
                                                          V338_1 == 2 ~ 1,
                                                          V338_1 == 3 ~ 0))
DE <- DE %>% mutate(homoco.may.adopt.exp.le_2 = case_when(V338_2 == 1 ~ 0,
                                                          V338_2 == 2 ~ 1,
                                                          V338_2 == 3 ~ 0))
DE <- DE %>% mutate(homoco.may.adopt.exp.dk_1 = case_when(V338_1 == 1 ~ 0,
                                                          V338_1 == 2 ~ 0,
                                                          V338_1 == 3 ~ 1))
DE <- DE %>% mutate(homoco.may.adopt.exp.dk_2 = case_when(V338_2 == 1 ~ 0,
                                                          V338_2 == 2 ~ 0,
                                                          V338_2 == 3 ~ 1))
#NL
#equal.pay.by.law
NL <- NL %>% mutate(equal.pay.by.law.exp.01_1 = case_when(V337_1 == 1 ~ 1,
                                                          V337_1 == 2 ~ 0))
NL <- NL %>% mutate(equal.pay.by.law.exp.01_2 = case_when(V337_2 == 1 ~ 1,
                                                          V337_2 == 2 ~ 0))
NL <- NL %>% mutate(equal.pay.by.law.exp.se_1 = case_when(V337_1 == 1 ~ 1,
                                                          V337_1 == 2 ~ 1,
                                                          V337_1 == 3 ~ 1))
NL <- NL %>% mutate(equal.pay.by.law.exp.se_2 = case_when(V337_2 == 1 ~ 1,
                                                          V337_2 == 2 ~ 1,
                                                          V337_2 == 3 ~ 1))
NL <- NL %>% mutate(equal.pay.by.law.exp.le_1 = case_when(V337_1 == 1 ~ 1,
                                                          V337_1 == 2 ~ 0,
                                                          V337_1 == 3 ~ 0))
NL <- NL %>% mutate(equal.pay.by.law.exp.le_2 = case_when(V337_2 == 1 ~ 1,
                                                          V337_2 == 2 ~ 0,
                                                          V337_2 == 3 ~ 0))
NL <- NL %>% mutate(equal.pay.by.law.exp.ri_1 = case_when(V337_1 == 1 ~ 0,
                                                          V337_1 == 2 ~ 1,
                                                          V337_1 == 3 ~ 0))
NL <- NL %>% mutate(equal.pay.by.law.exp.ri_2 = case_when(V337_2 == 1 ~ 0,
                                                          V337_2 == 2 ~ 1,
                                                          V337_2 == 3 ~ 0))
NL <- NL %>% mutate(equal.pay.by.law.exp.dk_1 = case_when(V337_1 == 1 ~ 0,
                                                          V337_1 == 2 ~ 0,
                                                          V337_1 == 3 ~ 1))
NL <- NL %>% mutate(equal.pay.by.law.exp.dk_2 = case_when(V337_2 == 1 ~ 0,
                                                          V337_2 == 2 ~ 0,
                                                          V337_2 == 3 ~ 1))
#homoco.may.adopt
NL <- NL %>% mutate(homoco.may.adopt.exp.01_1 = case_when(V338_1 == 2 ~ 1,
                                                          V338_1 == 1 ~ 0))
NL <- NL %>% mutate(homoco.may.adopt.exp.01_2 = case_when(V338_2 == 2 ~ 1,
                                                          V338_2 == 1 ~ 0))
NL <- NL %>% mutate(homoco.may.adopt.exp.se_1 = case_when(V338_1 == 1 ~ 1,
                                                          V338_1 == 2 ~ 1,
                                                          V338_1 == 3 ~ 1))
NL <- NL %>% mutate(homoco.may.adopt.exp.se_2 = case_when(V338_2 == 1 ~ 1,
                                                          V338_2 == 2 ~ 1,
                                                          V338_2 == 3 ~ 1))
NL <- NL %>% mutate(homoco.may.adopt.exp.ri_1 = case_when(V338_1 == 1 ~ 1,
                                                          V338_1 == 2 ~ 0,
                                                          V338_1 == 3 ~ 0))
NL <- NL %>% mutate(homoco.may.adopt.exp.ri_2 = case_when(V338_2 == 1 ~ 1,
                                                          V338_2 == 2 ~ 0,
                                                          V338_2 == 3 ~ 0))
NL <- NL %>% mutate(homoco.may.adopt.exp.le_1 = case_when(V338_1 == 1 ~ 0,
                                                          V338_1 == 2 ~ 1,
                                                          V338_1 == 3 ~ 0))
NL <- NL %>% mutate(homoco.may.adopt.exp.le_2 = case_when(V338_2 == 1 ~ 0,
                                                          V338_2 == 2 ~ 1,
                                                          V338_2 == 3 ~ 0))
NL <- NL %>% mutate(homoco.may.adopt.exp.dk_1 = case_when(V338_1 == 1 ~ 0,
                                                          V338_1 == 2 ~ 0,
                                                          V338_1 == 3 ~ 1))
NL <- NL %>% mutate(homoco.may.adopt.exp.dk_2 = case_when(V338_2 == 1 ~ 0,
                                                          V338_2 == 2 ~ 0,
                                                          V338_2 == 3 ~ 1))

#----------------------------#
#--- profiles politicians ---#
#----------------------------#

#FR
#profile gender
FR$idprof.exp.gen.1st <- FR$V10_1
FR$idprof.exp.gen.2nd <- FR$V10_2

FR <- FR %>% mutate(prof.exp.fem.1st = case_when(idprof.exp.gen.1st == 1  ~ 1,
                                                   idprof.exp.gen.1st == 2  ~ 1,
                                                   idprof.exp.gen.1st == 3  ~ 1,
                                                   idprof.exp.gen.1st == 4  ~ 1,
                                                   idprof.exp.gen.1st == 5  ~ 1,
                                                   idprof.exp.gen.1st == 6  ~ 1,
                                                   idprof.exp.gen.1st == 7  ~ 1,
                                                   idprof.exp.gen.1st == 8  ~ 1,
                                                   idprof.exp.gen.1st == 9  ~ 1,
                                                   idprof.exp.gen.1st == 10  ~ 0,
                                                   idprof.exp.gen.1st == 11  ~ 0,
                                                   idprof.exp.gen.1st == 12  ~ 0,
                                                   idprof.exp.gen.1st == 13  ~ 0,
                                                   idprof.exp.gen.1st == 14  ~ 0,
                                                   idprof.exp.gen.1st == 15  ~ 0,
                                                   idprof.exp.gen.1st == 16  ~ 0,
                                                   idprof.exp.gen.1st == 17  ~ 0,
                                                   idprof.exp.gen.1st == 18  ~ 0,
                                                   idprof.exp.gen.1st == 19  ~ 1,
                                                   idprof.exp.gen.1st == 20  ~ 1,
                                                   idprof.exp.gen.1st == 21  ~ 1,
                                                   idprof.exp.gen.1st == 22  ~ 1,
                                                   idprof.exp.gen.1st == 23  ~ 1,
                                                   idprof.exp.gen.1st == 24  ~ 1,
                                                   idprof.exp.gen.1st == 25  ~ 1,
                                                   idprof.exp.gen.1st == 26  ~ 1,
                                                   idprof.exp.gen.1st == 27  ~ 0,
                                                   idprof.exp.gen.1st == 28  ~ 0,
                                                   idprof.exp.gen.1st == 29  ~ 0,
                                                   idprof.exp.gen.1st == 30  ~ 0,
                                                   idprof.exp.gen.1st == 31  ~ 0,
                                                   idprof.exp.gen.1st == 32  ~ 0,
                                                   idprof.exp.gen.1st == 33  ~ 0,
                                                   idprof.exp.gen.1st == 34  ~ 0,
                                                   idprof.exp.gen.1st == 35  ~ 1,
                                                   idprof.exp.gen.1st == 36  ~ 1,
                                                   idprof.exp.gen.1st == 37  ~ 1,
                                                   idprof.exp.gen.1st == 38  ~ 1,
                                                   idprof.exp.gen.1st == 39  ~ 1,
                                                   idprof.exp.gen.1st == 40  ~ 1,
                                                   idprof.exp.gen.1st == 41  ~ 1,
                                                   idprof.exp.gen.1st == 42  ~ 1,
                                                   idprof.exp.gen.1st == 43  ~ 1,
                                                   idprof.exp.gen.1st == 44  ~ 1,
                                                   idprof.exp.gen.1st == 45  ~ 0,
                                                   idprof.exp.gen.1st == 46  ~ 0,
                                                   idprof.exp.gen.1st == 47  ~ 0,
                                                   idprof.exp.gen.1st == 48  ~ 0,
                                                   idprof.exp.gen.1st == 49  ~ 0,
                                                   idprof.exp.gen.1st == 50  ~ 0,
                                                   idprof.exp.gen.1st == 51  ~ 0,
                                                   idprof.exp.gen.1st == 52  ~ 0,
                                                   idprof.exp.gen.1st == 53  ~ 0,
                                                   idprof.exp.gen.1st == 54  ~ 0,
                                                   idprof.exp.gen.1st == 55  ~ 1,
                                                   idprof.exp.gen.1st == 56  ~ 1,
                                                   idprof.exp.gen.1st == 57  ~ 1,
                                                   idprof.exp.gen.1st == 58  ~ 1,
                                                   idprof.exp.gen.1st == 59  ~ 1,
                                                   idprof.exp.gen.1st == 60  ~ 1,
                                                   idprof.exp.gen.1st == 61  ~ 1,
                                                   idprof.exp.gen.1st == 62  ~ 1,
                                                   idprof.exp.gen.1st == 63  ~ 1,
                                                   idprof.exp.gen.1st == 64  ~ 0,
                                                   idprof.exp.gen.1st == 65  ~ 0,
                                                   idprof.exp.gen.1st == 66  ~ 0,
                                                   idprof.exp.gen.1st == 67  ~ 0,
                                                   idprof.exp.gen.1st == 68  ~ 0,
                                                   idprof.exp.gen.1st == 69  ~ 0,
                                                   idprof.exp.gen.1st == 70  ~ 0,
                                                   idprof.exp.gen.1st == 71  ~ 0,
                                                   idprof.exp.gen.1st == 72  ~ 0,
                                                   idprof.exp.gen.1st == 73  ~ 0,
                                                   idprof.exp.gen.1st == 74  ~ 0,
                                                   idprof.exp.gen.1st == 75  ~ 0,
                                                   idprof.exp.gen.1st == 76  ~ 1,
                                                   idprof.exp.gen.1st == 77  ~ 1,
                                                   idprof.exp.gen.1st == 78  ~ 1,
                                                   idprof.exp.gen.1st == 79  ~ 1,
                                                   idprof.exp.gen.1st == 80  ~ 1))

FR <- FR %>% mutate(prof.exp.fem.2nd = case_when(idprof.exp.gen.2nd == 1  ~ 1,
                                                   idprof.exp.gen.2nd == 2  ~ 1,
                                                   idprof.exp.gen.2nd == 3  ~ 1,
                                                   idprof.exp.gen.2nd == 4  ~ 1,
                                                   idprof.exp.gen.2nd == 5  ~ 1,
                                                   idprof.exp.gen.2nd == 6  ~ 1,
                                                   idprof.exp.gen.2nd == 7  ~ 1,
                                                   idprof.exp.gen.2nd == 8  ~ 1,
                                                   idprof.exp.gen.2nd == 9  ~ 1,
                                                   idprof.exp.gen.2nd == 10  ~ 0,
                                                   idprof.exp.gen.2nd == 11  ~ 0,
                                                   idprof.exp.gen.2nd == 12  ~ 0,
                                                   idprof.exp.gen.2nd == 13  ~ 0,
                                                   idprof.exp.gen.2nd == 14  ~ 0,
                                                   idprof.exp.gen.2nd == 15  ~ 0,
                                                   idprof.exp.gen.2nd == 16  ~ 0,
                                                   idprof.exp.gen.2nd == 17  ~ 0,
                                                   idprof.exp.gen.2nd == 18  ~ 0,
                                                   idprof.exp.gen.2nd == 19  ~ 1,
                                                   idprof.exp.gen.2nd == 20  ~ 1,
                                                   idprof.exp.gen.2nd == 21  ~ 1,
                                                   idprof.exp.gen.2nd == 22  ~ 1,
                                                   idprof.exp.gen.2nd == 23  ~ 1,
                                                   idprof.exp.gen.2nd == 24  ~ 1,
                                                   idprof.exp.gen.2nd == 25  ~ 1,
                                                   idprof.exp.gen.2nd == 26  ~ 1,
                                                   idprof.exp.gen.2nd == 27  ~ 0,
                                                   idprof.exp.gen.2nd == 28  ~ 0,
                                                   idprof.exp.gen.2nd == 29  ~ 0,
                                                   idprof.exp.gen.2nd == 30  ~ 0,
                                                   idprof.exp.gen.2nd == 31  ~ 0,
                                                   idprof.exp.gen.2nd == 32  ~ 0,
                                                   idprof.exp.gen.2nd == 33  ~ 0,
                                                   idprof.exp.gen.2nd == 34  ~ 0,
                                                   idprof.exp.gen.2nd == 35  ~ 1,
                                                   idprof.exp.gen.2nd == 36  ~ 1,
                                                   idprof.exp.gen.2nd == 37  ~ 1,
                                                   idprof.exp.gen.2nd == 38  ~ 1,
                                                   idprof.exp.gen.2nd == 39  ~ 1,
                                                   idprof.exp.gen.2nd == 40  ~ 1,
                                                   idprof.exp.gen.2nd == 41  ~ 1,
                                                   idprof.exp.gen.2nd == 42  ~ 1,
                                                   idprof.exp.gen.2nd == 43  ~ 1,
                                                   idprof.exp.gen.2nd == 44  ~ 1,
                                                   idprof.exp.gen.2nd == 45  ~ 0,
                                                   idprof.exp.gen.2nd == 46  ~ 0,
                                                   idprof.exp.gen.2nd == 47  ~ 0,
                                                   idprof.exp.gen.2nd == 48  ~ 0,
                                                   idprof.exp.gen.2nd == 49  ~ 0,
                                                   idprof.exp.gen.2nd == 50  ~ 0,
                                                   idprof.exp.gen.2nd == 51  ~ 0,
                                                   idprof.exp.gen.2nd == 52  ~ 0,
                                                   idprof.exp.gen.2nd == 53  ~ 0,
                                                   idprof.exp.gen.2nd == 54  ~ 0,
                                                   idprof.exp.gen.2nd == 55  ~ 1,
                                                   idprof.exp.gen.2nd == 56  ~ 1,
                                                   idprof.exp.gen.2nd == 57  ~ 1,
                                                   idprof.exp.gen.2nd == 58  ~ 1,
                                                   idprof.exp.gen.2nd == 59  ~ 1,
                                                   idprof.exp.gen.2nd == 60  ~ 1,
                                                   idprof.exp.gen.2nd == 61  ~ 1,
                                                   idprof.exp.gen.2nd == 62  ~ 1,
                                                   idprof.exp.gen.2nd == 63  ~ 1,
                                                   idprof.exp.gen.2nd == 64  ~ 0,
                                                   idprof.exp.gen.2nd == 65  ~ 0,
                                                   idprof.exp.gen.2nd == 66  ~ 0,
                                                   idprof.exp.gen.2nd == 67  ~ 0,
                                                   idprof.exp.gen.2nd == 68  ~ 0,
                                                   idprof.exp.gen.2nd == 69  ~ 0,
                                                   idprof.exp.gen.2nd == 70  ~ 0,
                                                   idprof.exp.gen.2nd == 71  ~ 0,
                                                   idprof.exp.gen.2nd == 72  ~ 0,
                                                   idprof.exp.gen.2nd == 73  ~ 0,
                                                   idprof.exp.gen.2nd == 74  ~ 0,
                                                   idprof.exp.gen.2nd == 75  ~ 0,
                                                   idprof.exp.gen.2nd == 76  ~ 1,
                                                   idprof.exp.gen.2nd == 77  ~ 1,
                                                   idprof.exp.gen.2nd == 78  ~ 1,
                                                   idprof.exp.gen.2nd == 79  ~ 1,
                                                   idprof.exp.gen.2nd == 80  ~ 1))

#idprof.exp.nogen
FR$idprof.exp.nogen.1st <- FR$V40_1
FR$idprof.exp.nogen.2nd <- FR$V40_2

FR <- FR %>% mutate(idprof.exp.1st = case_when(prof.exp.fem.1st == 1 & idprof.exp.nogen.1st == 1 ~ "Female Turkish Muslim",
                                               prof.exp.fem.1st == 0 & idprof.exp.nogen.1st == 1 ~ "Male Turkish Muslim",
                                               prof.exp.fem.1st == 1 & idprof.exp.nogen.1st == 2 ~ "Female Turkish Christian",
                                               prof.exp.fem.1st == 0 & idprof.exp.nogen.1st == 2 ~ "Male Turkish Christian",
                                               prof.exp.fem.1st == 1 & idprof.exp.nogen.1st == 3 ~ "Female Turkish Non Religious",
                                               prof.exp.fem.1st == 0 & idprof.exp.nogen.1st == 3 ~ "Male Turkish Non Religious",
                                               prof.exp.fem.1st == 1 & idprof.exp.nogen.1st == 4 ~ "Female Maghrebi Muslim",
                                               prof.exp.fem.1st == 0 & idprof.exp.nogen.1st == 4 ~ "Male Maghrebi Muslim",
                                               prof.exp.fem.1st == 1 & idprof.exp.nogen.1st == 5 ~ "Female Maghrebi Christian",
                                               prof.exp.fem.1st == 0 & idprof.exp.nogen.1st == 5 ~ "Male Maghrebi Christian",
                                               prof.exp.fem.1st == 1 & idprof.exp.nogen.1st == 6 ~ "Female Maghrebi Non Religious",
                                               prof.exp.fem.1st == 0 & idprof.exp.nogen.1st == 6 ~ "Male Maghrebi Non Religious",
                                               prof.exp.fem.1st == 1 & idprof.exp.nogen.1st == 7 ~ "Female SSA Muslim",
                                               prof.exp.fem.1st == 0 & idprof.exp.nogen.1st == 7 ~ "Male SSA Muslim",
                                               prof.exp.fem.1st == 1 & idprof.exp.nogen.1st == 8 ~ "Female SSA Christian",
                                               prof.exp.fem.1st == 0 & idprof.exp.nogen.1st == 8 ~ "Male SSA Christian",
                                               prof.exp.fem.1st == 1 & idprof.exp.nogen.1st == 9 ~ "Female SSA Non Religious",
                                               prof.exp.fem.1st == 0 & idprof.exp.nogen.1st == 9 ~ "Male SSA Non Religious",
                                               prof.exp.fem.1st == 1 & idprof.exp.nogen.1st == 10 ~ "Female French Muslim",
                                               prof.exp.fem.1st == 0 & idprof.exp.nogen.1st == 10 ~ "Male French Muslim",
                                               prof.exp.fem.1st == 1 & idprof.exp.nogen.1st == 11 ~ "Female French Christian",
                                               prof.exp.fem.1st == 0 & idprof.exp.nogen.1st == 11 ~ "Male French Christian",
                                               prof.exp.fem.1st == 1 & idprof.exp.nogen.1st == 12 ~ "Female French Non Religious",
                                               prof.exp.fem.1st == 0 & idprof.exp.nogen.1st == 12 ~ "Male French Non Religious"))

FR <- FR %>% mutate(idprof.exp.2nd = case_when(prof.exp.fem.2nd == 1 & idprof.exp.nogen.2nd == 1 ~ "Female Turkish Muslim",
                                               prof.exp.fem.2nd == 0 & idprof.exp.nogen.2nd == 1 ~ "Male Turkish Muslim",
                                               prof.exp.fem.2nd == 1 & idprof.exp.nogen.2nd == 2 ~ "Female Turkish Christian",
                                               prof.exp.fem.2nd == 0 & idprof.exp.nogen.2nd == 2 ~ "Male Turkish Christian",
                                               prof.exp.fem.2nd == 1 & idprof.exp.nogen.2nd == 3 ~ "Female Turkish Non Religious",
                                               prof.exp.fem.2nd == 0 & idprof.exp.nogen.2nd == 3 ~ "Male Turkish Non Religious",
                                               prof.exp.fem.2nd == 1 & idprof.exp.nogen.2nd == 4 ~ "Female Maghrebi Muslim",
                                               prof.exp.fem.2nd == 0 & idprof.exp.nogen.2nd == 4 ~ "Male Maghrebi Muslim",
                                               prof.exp.fem.2nd == 1 & idprof.exp.nogen.2nd == 5 ~ "Female Maghrebi Christian",
                                               prof.exp.fem.2nd == 0 & idprof.exp.nogen.2nd == 5 ~ "Male Maghrebi Christian",
                                               prof.exp.fem.2nd == 1 & idprof.exp.nogen.2nd == 6 ~ "Female Maghrebi Non Religious",
                                               prof.exp.fem.2nd == 0 & idprof.exp.nogen.2nd == 6 ~ "Male Maghrebi Non Religious",
                                               prof.exp.fem.2nd == 1 & idprof.exp.nogen.2nd == 7 ~ "Female SSA Muslim",
                                               prof.exp.fem.2nd == 0 & idprof.exp.nogen.2nd == 7 ~ "Male SSA Muslim",
                                               prof.exp.fem.2nd == 1 & idprof.exp.nogen.2nd == 8 ~ "Female SSA Christian",
                                               prof.exp.fem.2nd == 0 & idprof.exp.nogen.2nd == 8 ~ "Male SSA Christian",
                                               prof.exp.fem.2nd == 1 & idprof.exp.nogen.2nd == 9 ~ "Female SSA Non Religious",
                                               prof.exp.fem.2nd == 0 & idprof.exp.nogen.2nd == 9 ~ "Male SSA Non Religious",
                                               prof.exp.fem.2nd == 1 & idprof.exp.nogen.2nd == 10 ~ "Female French Muslim",
                                               prof.exp.fem.2nd == 0 & idprof.exp.nogen.2nd == 10 ~ "Male French Muslim",
                                               prof.exp.fem.2nd == 1 & idprof.exp.nogen.2nd == 11 ~ "Female French Christian",
                                               prof.exp.fem.2nd == 0 & idprof.exp.nogen.2nd == 11 ~ "Male French Christian",
                                               prof.exp.fem.2nd == 1 & idprof.exp.nogen.2nd == 12 ~ "Female French Non Religious",
                                               prof.exp.fem.2nd == 0 & idprof.exp.nogen.2nd == 12 ~ "Male French Non Religious"))

#prof.exp.ile religion
FR <- FR %>% mutate(prof.exp.Mu.1st = case_when(idprof.exp.1st == "Female Turkish Muslim" ~ 1,
                                                idprof.exp.1st == "Male Turkish Muslim" ~ 1,
                                                idprof.exp.1st == "Female Turkish Christian" ~ 0,
                                                idprof.exp.1st == "Male Turkish Christian" ~ 0,
                                                idprof.exp.1st == "Female Turkish Non Religious" ~ 0,
                                                idprof.exp.1st == "Male Turkish Non Religious" ~ 0,
                                                
                                                idprof.exp.1st == "Female Maghrebi Muslim" ~ 1,
                                                idprof.exp.1st == "Male Maghrebi Muslim" ~ 1,
                                                idprof.exp.1st == "Female Maghrebi Christian" ~ 0,
                                                idprof.exp.1st == "Male Maghrebi Christian" ~ 0,
                                                idprof.exp.1st == "Female Maghrebi Non Religious" ~ 0,
                                                idprof.exp.1st == "Male Maghrebi Non Religious" ~ 0,
                                                
                                                idprof.exp.1st == "Female SSA Muslim" ~ 1,
                                                idprof.exp.1st == "Male SSA Muslim" ~ 1,
                                                idprof.exp.1st == "Female SSA Christian" ~ 0,
                                                idprof.exp.1st == "Male SSA Christian" ~ 0,
                                                idprof.exp.1st == "Female SSA Non Religious" ~ 0,
                                                idprof.exp.1st == "Male SSA Non Religious" ~ 0,
                                                
                                                idprof.exp.1st == "Female French Muslim" ~ 1,
                                                idprof.exp.1st == "Male French Muslim" ~ 1,
                                                idprof.exp.1st == "Female French Christian" ~ 0,
                                                idprof.exp.1st == "Male French Christian" ~ 0,
                                                idprof.exp.1st == "Female French Non Religious" ~ 0,
                                                idprof.exp.1st == "Male French Non Religious" ~ 0))

FR <- FR %>% mutate(prof.exp.Chr.1st = case_when(idprof.exp.1st == "Female Turkish Muslim" ~ 0,
                                                 idprof.exp.1st == "Male Turkish Muslim" ~ 0,
                                                 idprof.exp.1st == "Female Turkish Christian" ~ 1,
                                                 idprof.exp.1st == "Male Turkish Christian" ~ 1,
                                                 idprof.exp.1st == "Female Turkish Non Religious" ~ 0,
                                                 idprof.exp.1st == "Male Turkish Non Religious" ~ 0,
                                                 
                                                 idprof.exp.1st == "Female Maghrebi Muslim" ~ 0,
                                                 idprof.exp.1st == "Male Maghrebi Muslim" ~ 0,
                                                 idprof.exp.1st == "Female Maghrebi Christian" ~ 1,
                                                 idprof.exp.1st == "Male Maghrebi Christian" ~ 1,
                                                 idprof.exp.1st == "Female Maghrebi Non Religious" ~ 0,
                                                 idprof.exp.1st == "Male Maghrebi Non Religious" ~ 0,
                                                 
                                                 idprof.exp.1st == "Female SSA Muslim" ~ 0,
                                                 idprof.exp.1st == "Male SSA Muslim" ~ 0,
                                                 idprof.exp.1st == "Female SSA Christian" ~ 1,
                                                 idprof.exp.1st == "Male SSA Christian" ~ 1,
                                                 idprof.exp.1st == "Female SSA Non Religious" ~ 0,
                                                 idprof.exp.1st == "Male SSA Non Religious" ~ 0,
                                                 
                                                 idprof.exp.1st == "Female French Muslim" ~ 0,
                                                 idprof.exp.1st == "Male French Muslim" ~ 0,
                                                 idprof.exp.1st == "Female French Christian" ~ 1,
                                                 idprof.exp.1st == "Male French Christian" ~ 1,
                                                 idprof.exp.1st == "Female French Non Religious" ~ 0,
                                                 idprof.exp.1st == "Male French Non Religious" ~ 0))

FR <- FR %>% mutate(prof.exp.No.1st = case_when(idprof.exp.1st == "Female Turkish Muslim" ~ 0,
                                                idprof.exp.1st == "Male Turkish Muslim" ~ 0,
                                                idprof.exp.1st == "Female Turkish Christian" ~ 0,
                                                idprof.exp.1st == "Male Turkish Christian" ~ 0,
                                                idprof.exp.1st == "Female Turkish Non Religious" ~ 1,
                                                idprof.exp.1st == "Male Turkish Non Religious" ~ 1,
                                                
                                                idprof.exp.1st == "Female Maghrebi Muslim" ~ 0,
                                                idprof.exp.1st == "Male Maghrebi Muslim" ~ 0,
                                                idprof.exp.1st == "Female Maghrebi Christian" ~ 0,
                                                idprof.exp.1st == "Male Maghrebi Christian" ~ 0,
                                                idprof.exp.1st == "Female Maghrebi Non Religious" ~ 1,
                                                idprof.exp.1st == "Male Maghrebi Non Religious" ~ 1,
                                                
                                                idprof.exp.1st == "Female SSA Muslim" ~ 0,
                                                idprof.exp.1st == "Male SSA Muslim" ~ 0,
                                                idprof.exp.1st == "Female SSA Christian" ~ 0,
                                                idprof.exp.1st == "Male SSA Christian" ~ 0,
                                                idprof.exp.1st == "Female SSA Non Religious" ~ 1,
                                                idprof.exp.1st == "Male SSA Non Religious" ~ 1,
                                                
                                                idprof.exp.1st == "Female French Muslim" ~ 0,
                                                idprof.exp.1st == "Male French Muslim" ~ 0,
                                                idprof.exp.1st == "Female French Christian" ~ 0,
                                                idprof.exp.1st == "Male French Christian" ~ 0,
                                                idprof.exp.1st == "Female French Non Religious" ~ 1,
                                                idprof.exp.1st == "Male French Non Religious" ~ 1))

#2nd
FR <- FR %>% mutate(prof.exp.Mu.2nd = case_when(idprof.exp.2nd == "Female Turkish Muslim" ~ 1,
                                                idprof.exp.2nd == "Male Turkish Muslim" ~ 1,
                                                idprof.exp.2nd == "Female Turkish Christian" ~ 0,
                                                idprof.exp.2nd == "Male Turkish Christian" ~ 0,
                                                idprof.exp.2nd == "Female Turkish Non Religious" ~ 0,
                                                idprof.exp.2nd == "Male Turkish Non Religious" ~ 0,
                                                
                                                idprof.exp.2nd == "Female Maghrebi Muslim" ~ 1,
                                                idprof.exp.2nd == "Male Maghrebi Muslim" ~ 1,
                                                idprof.exp.2nd == "Female Maghrebi Christian" ~ 0,
                                                idprof.exp.2nd == "Male Maghrebi Christian" ~ 0,
                                                idprof.exp.2nd == "Female Maghrebi Non Religious" ~ 0,
                                                idprof.exp.2nd == "Male Maghrebi Non Religious" ~ 0,
                                                
                                                idprof.exp.2nd == "Female SSA Muslim" ~ 1,
                                                idprof.exp.2nd == "Male SSA Muslim" ~ 1,
                                                idprof.exp.2nd == "Female SSA Christian" ~ 0,
                                                idprof.exp.2nd == "Male SSA Christian" ~ 0,
                                                idprof.exp.2nd == "Female SSA Non Religious" ~ 0,
                                                idprof.exp.2nd == "Male SSA Non Religious" ~ 0,
                                                
                                                idprof.exp.2nd == "Female French Muslim" ~ 1,
                                                idprof.exp.2nd == "Male French Muslim" ~ 1,
                                                idprof.exp.2nd == "Female French Christian" ~ 0,
                                                idprof.exp.2nd == "Male French Christian" ~ 0,
                                                idprof.exp.2nd == "Female French Non Religious" ~ 0,
                                                idprof.exp.2nd == "Male French Non Religious" ~ 0))

FR <- FR %>% mutate(prof.exp.Chr.2nd = case_when(idprof.exp.2nd == "Female Turkish Muslim" ~ 0,
                                                 idprof.exp.2nd == "Male Turkish Muslim" ~ 0,
                                                 idprof.exp.2nd == "Female Turkish Christian" ~ 1,
                                                 idprof.exp.2nd == "Male Turkish Christian" ~ 1,
                                                 idprof.exp.2nd == "Female Turkish Non Religious" ~ 0,
                                                 idprof.exp.2nd == "Male Turkish Non Religious" ~ 0,
                                                 
                                                 idprof.exp.2nd == "Female Maghrebi Muslim" ~ 0,
                                                 idprof.exp.2nd == "Male Maghrebi Muslim" ~ 0,
                                                 idprof.exp.2nd == "Female Maghrebi Christian" ~ 1,
                                                 idprof.exp.2nd == "Male Maghrebi Christian" ~ 1,
                                                 idprof.exp.2nd == "Female Maghrebi Non Religious" ~ 0,
                                                 idprof.exp.2nd == "Male Maghrebi Non Religious" ~ 0,
                                                 
                                                 idprof.exp.2nd == "Female SSA Muslim" ~ 0,
                                                 idprof.exp.2nd == "Male SSA Muslim" ~ 0,
                                                 idprof.exp.2nd == "Female SSA Christian" ~ 1,
                                                 idprof.exp.2nd == "Male SSA Christian" ~ 1,
                                                 idprof.exp.2nd == "Female SSA Non Religious" ~ 0,
                                                 idprof.exp.2nd == "Male SSA Non Religious" ~ 0,
                                                 
                                                 idprof.exp.2nd == "Female French Muslim" ~ 0,
                                                 idprof.exp.2nd == "Male French Muslim" ~ 0,
                                                 idprof.exp.2nd == "Female French Christian" ~ 1,
                                                 idprof.exp.2nd == "Male French Christian" ~ 1,
                                                 idprof.exp.2nd == "Female French Non Religious" ~ 0,
                                                 idprof.exp.2nd == "Male French Non Religious" ~ 0))

FR <- FR %>% mutate(prof.exp.No.2nd = case_when(idprof.exp.2nd == "Female Turkish Muslim" ~ 0,
                                                idprof.exp.2nd == "Male Turkish Muslim" ~ 0,
                                                idprof.exp.2nd == "Female Turkish Christian" ~ 0,
                                                idprof.exp.2nd == "Male Turkish Christian" ~ 0,
                                                idprof.exp.2nd == "Female Turkish Non Religious" ~ 1,
                                                idprof.exp.2nd == "Male Turkish Non Religious" ~ 1,
                                                
                                                idprof.exp.2nd == "Female Maghrebi Muslim" ~ 0,
                                                idprof.exp.2nd == "Male Maghrebi Muslim" ~ 0,
                                                idprof.exp.2nd == "Female Maghrebi Christian" ~ 0,
                                                idprof.exp.2nd == "Male Maghrebi Christian" ~ 0,
                                                idprof.exp.2nd == "Female Maghrebi Non Religious" ~ 1,
                                                idprof.exp.2nd == "Male Maghrebi Non Religious" ~ 1,
                                                
                                                idprof.exp.2nd == "Female SSA Muslim" ~ 0,
                                                idprof.exp.2nd == "Male SSA Muslim" ~ 0,
                                                idprof.exp.2nd == "Female SSA Christian" ~ 0,
                                                idprof.exp.2nd == "Male SSA Christian" ~ 0,
                                                idprof.exp.2nd == "Female SSA Non Religious" ~ 1,
                                                idprof.exp.2nd == "Male SSA Non Religious" ~ 1,
                                                
                                                idprof.exp.2nd == "Female French Muslim" ~ 0,
                                                idprof.exp.2nd == "Male French Muslim" ~ 0,
                                                idprof.exp.2nd == "Female French Christian" ~ 0,
                                                idprof.exp.2nd == "Male French Christian" ~ 0,
                                                idprof.exp.2nd == "Female French Non Religious" ~ 1,
                                                idprof.exp.2nd == "Male French Non Religious" ~ 1))

#DE
#profile gender
DE$idprof.exp.gen.1st <- DE$V10_1
DE$idprof.exp.gen.2nd <- DE$V10_2

DE <- DE %>% mutate(prof.exp.fem.1st = case_when(idprof.exp.gen.1st == 1  ~ 1,
                                                   idprof.exp.gen.1st == 2  ~ 1,
                                                   idprof.exp.gen.1st == 3  ~ 1,
                                                   idprof.exp.gen.1st == 4  ~ 1,
                                                   idprof.exp.gen.1st == 5  ~ 1,
                                                   idprof.exp.gen.1st == 6  ~ 1,
                                                   idprof.exp.gen.1st == 7  ~ 1,
                                                   idprof.exp.gen.1st == 8  ~ 1,
                                                   idprof.exp.gen.1st == 9  ~ 1,
                                                   idprof.exp.gen.1st == 10  ~ 0,
                                                   idprof.exp.gen.1st == 11  ~ 0,
                                                   idprof.exp.gen.1st == 12  ~ 0,
                                                   idprof.exp.gen.1st == 13  ~ 0,
                                                   idprof.exp.gen.1st == 14  ~ 0,
                                                   idprof.exp.gen.1st == 15  ~ 0,
                                                   idprof.exp.gen.1st == 16  ~ 0,
                                                   idprof.exp.gen.1st == 17  ~ 0,
                                                   idprof.exp.gen.1st == 18  ~ 0,
                                                   idprof.exp.gen.1st == 19  ~ 1,
                                                   idprof.exp.gen.1st == 20  ~ 1,
                                                   idprof.exp.gen.1st == 21  ~ 1,
                                                   idprof.exp.gen.1st == 22  ~ 1,
                                                   idprof.exp.gen.1st == 23  ~ 1,
                                                   idprof.exp.gen.1st == 24  ~ 1,
                                                   idprof.exp.gen.1st == 25  ~ 1,
                                                   idprof.exp.gen.1st == 26  ~ 1,
                                                   idprof.exp.gen.1st == 27  ~ 0,
                                                   idprof.exp.gen.1st == 28  ~ 0,
                                                   idprof.exp.gen.1st == 29  ~ 0,
                                                   idprof.exp.gen.1st == 30  ~ 0,
                                                   idprof.exp.gen.1st == 31  ~ 0,
                                                   idprof.exp.gen.1st == 32  ~ 0,
                                                   idprof.exp.gen.1st == 33  ~ 0,
                                                   idprof.exp.gen.1st == 34  ~ 0,
                                                   idprof.exp.gen.1st == 35  ~ 1,
                                                   idprof.exp.gen.1st == 36  ~ 1,
                                                   idprof.exp.gen.1st == 37  ~ 1,
                                                   idprof.exp.gen.1st == 38  ~ 1,
                                                   idprof.exp.gen.1st == 39  ~ 1,
                                                   idprof.exp.gen.1st == 40  ~ 1,
                                                   idprof.exp.gen.1st == 41  ~ 1,
                                                   idprof.exp.gen.1st == 42  ~ 1,
                                                   idprof.exp.gen.1st == 43  ~ 1,
                                                   idprof.exp.gen.1st == 44  ~ 1,
                                                   idprof.exp.gen.1st == 45  ~ 0,
                                                   idprof.exp.gen.1st == 46  ~ 0,
                                                   idprof.exp.gen.1st == 47  ~ 0,
                                                   idprof.exp.gen.1st == 48  ~ 0,
                                                   idprof.exp.gen.1st == 49  ~ 0,
                                                   idprof.exp.gen.1st == 50  ~ 0,
                                                   idprof.exp.gen.1st == 51  ~ 0,
                                                   idprof.exp.gen.1st == 52  ~ 0,
                                                   idprof.exp.gen.1st == 53  ~ 0,
                                                   idprof.exp.gen.1st == 54  ~ 0,
                                                   idprof.exp.gen.1st == 55  ~ 1,
                                                   idprof.exp.gen.1st == 56  ~ 1,
                                                   idprof.exp.gen.1st == 57  ~ 1,
                                                   idprof.exp.gen.1st == 58  ~ 1,
                                                   idprof.exp.gen.1st == 59  ~ 1,
                                                   idprof.exp.gen.1st == 60  ~ 1,
                                                   idprof.exp.gen.1st == 61  ~ 1,
                                                   idprof.exp.gen.1st == 62  ~ 1,
                                                   idprof.exp.gen.1st == 63  ~ 1,
                                                   idprof.exp.gen.1st == 64  ~ 0,
                                                   idprof.exp.gen.1st == 65  ~ 0,
                                                   idprof.exp.gen.1st == 66  ~ 0,
                                                   idprof.exp.gen.1st == 67  ~ 0,
                                                   idprof.exp.gen.1st == 68  ~ 0,
                                                   idprof.exp.gen.1st == 69  ~ 0,
                                                   idprof.exp.gen.1st == 70  ~ 0,
                                                   idprof.exp.gen.1st == 71  ~ 0,
                                                   idprof.exp.gen.1st == 72  ~ 0,
                                                   idprof.exp.gen.1st == 73  ~ 0,
                                                   idprof.exp.gen.1st == 74  ~ 0,
                                                   idprof.exp.gen.1st == 75  ~ 0,
                                                   idprof.exp.gen.1st == 76  ~ 1,
                                                   idprof.exp.gen.1st == 77  ~ 1,
                                                   idprof.exp.gen.1st == 78  ~ 1,
                                                   idprof.exp.gen.1st == 79  ~ 1,
                                                   idprof.exp.gen.1st == 80  ~ 1))

DE <- DE %>% mutate(prof.exp.fem.2nd = case_when(idprof.exp.gen.2nd == 1  ~ 1,
                                                   idprof.exp.gen.2nd == 2  ~ 1,
                                                   idprof.exp.gen.2nd == 3  ~ 1,
                                                   idprof.exp.gen.2nd == 4  ~ 1,
                                                   idprof.exp.gen.2nd == 5  ~ 1,
                                                   idprof.exp.gen.2nd == 6  ~ 1,
                                                   idprof.exp.gen.2nd == 7  ~ 1,
                                                   idprof.exp.gen.2nd == 8  ~ 1,
                                                   idprof.exp.gen.2nd == 9  ~ 1,
                                                   idprof.exp.gen.2nd == 10  ~ 0,
                                                   idprof.exp.gen.2nd == 11  ~ 0,
                                                   idprof.exp.gen.2nd == 12  ~ 0,
                                                   idprof.exp.gen.2nd == 13  ~ 0,
                                                   idprof.exp.gen.2nd == 14  ~ 0,
                                                   idprof.exp.gen.2nd == 15  ~ 0,
                                                   idprof.exp.gen.2nd == 16  ~ 0,
                                                   idprof.exp.gen.2nd == 17  ~ 0,
                                                   idprof.exp.gen.2nd == 18  ~ 0,
                                                   idprof.exp.gen.2nd == 19  ~ 1,
                                                   idprof.exp.gen.2nd == 20  ~ 1,
                                                   idprof.exp.gen.2nd == 21  ~ 1,
                                                   idprof.exp.gen.2nd == 22  ~ 1,
                                                   idprof.exp.gen.2nd == 23  ~ 1,
                                                   idprof.exp.gen.2nd == 24  ~ 1,
                                                   idprof.exp.gen.2nd == 25  ~ 1,
                                                   idprof.exp.gen.2nd == 26  ~ 1,
                                                   idprof.exp.gen.2nd == 27  ~ 0,
                                                   idprof.exp.gen.2nd == 28  ~ 0,
                                                   idprof.exp.gen.2nd == 29  ~ 0,
                                                   idprof.exp.gen.2nd == 30  ~ 0,
                                                   idprof.exp.gen.2nd == 31  ~ 0,
                                                   idprof.exp.gen.2nd == 32  ~ 0,
                                                   idprof.exp.gen.2nd == 33  ~ 0,
                                                   idprof.exp.gen.2nd == 34  ~ 0,
                                                   idprof.exp.gen.2nd == 35  ~ 1,
                                                   idprof.exp.gen.2nd == 36  ~ 1,
                                                   idprof.exp.gen.2nd == 37  ~ 1,
                                                   idprof.exp.gen.2nd == 38  ~ 1,
                                                   idprof.exp.gen.2nd == 39  ~ 1,
                                                   idprof.exp.gen.2nd == 40  ~ 1,
                                                   idprof.exp.gen.2nd == 41  ~ 1,
                                                   idprof.exp.gen.2nd == 42  ~ 1,
                                                   idprof.exp.gen.2nd == 43  ~ 1,
                                                   idprof.exp.gen.2nd == 44  ~ 1,
                                                   idprof.exp.gen.2nd == 45  ~ 0,
                                                   idprof.exp.gen.2nd == 46  ~ 0,
                                                   idprof.exp.gen.2nd == 47  ~ 0,
                                                   idprof.exp.gen.2nd == 48  ~ 0,
                                                   idprof.exp.gen.2nd == 49  ~ 0,
                                                   idprof.exp.gen.2nd == 50  ~ 0,
                                                   idprof.exp.gen.2nd == 51  ~ 0,
                                                   idprof.exp.gen.2nd == 52  ~ 0,
                                                   idprof.exp.gen.2nd == 53  ~ 0,
                                                   idprof.exp.gen.2nd == 54  ~ 0,
                                                   idprof.exp.gen.2nd == 55  ~ 1,
                                                   idprof.exp.gen.2nd == 56  ~ 1,
                                                   idprof.exp.gen.2nd == 57  ~ 1,
                                                   idprof.exp.gen.2nd == 58  ~ 1,
                                                   idprof.exp.gen.2nd == 59  ~ 1,
                                                   idprof.exp.gen.2nd == 60  ~ 1,
                                                   idprof.exp.gen.2nd == 61  ~ 1,
                                                   idprof.exp.gen.2nd == 62  ~ 1,
                                                   idprof.exp.gen.2nd == 63  ~ 1,
                                                   idprof.exp.gen.2nd == 64  ~ 0,
                                                   idprof.exp.gen.2nd == 65  ~ 0,
                                                   idprof.exp.gen.2nd == 66  ~ 0,
                                                   idprof.exp.gen.2nd == 67  ~ 0,
                                                   idprof.exp.gen.2nd == 68  ~ 0,
                                                   idprof.exp.gen.2nd == 69  ~ 0,
                                                   idprof.exp.gen.2nd == 70  ~ 0,
                                                   idprof.exp.gen.2nd == 71  ~ 0,
                                                   idprof.exp.gen.2nd == 72  ~ 0,
                                                   idprof.exp.gen.2nd == 73  ~ 0,
                                                   idprof.exp.gen.2nd == 74  ~ 0,
                                                   idprof.exp.gen.2nd == 75  ~ 0,
                                                   idprof.exp.gen.2nd == 76  ~ 1,
                                                   idprof.exp.gen.2nd == 77  ~ 1,
                                                   idprof.exp.gen.2nd == 78  ~ 1,
                                                   idprof.exp.gen.2nd == 79  ~ 1,
                                                   idprof.exp.gen.2nd == 80  ~ 1))

#idprof.exp.nogen
DE$idprof.exp.nogen.1st <- DE$V40_1
DE$idprof.exp.nogen.2nd <- DE$V40_2

DE <- DE %>% mutate(idprof.exp.1st = case_when(prof.exp.fem.1st == 1 & idprof.exp.nogen.1st == 1 ~ "Female Turkish Muslim",
                                                  prof.exp.fem.1st == 0 & idprof.exp.nogen.1st == 1 ~ "Male Turkish Muslim",
                                                  prof.exp.fem.1st == 1 & idprof.exp.nogen.1st == 2 ~ "Female Turkish Christian",
                                                  prof.exp.fem.1st == 0 & idprof.exp.nogen.1st == 2 ~ "Male Turkish Christian",
                                                  prof.exp.fem.1st == 1 & idprof.exp.nogen.1st == 3 ~ "Female Turkish Non Religious",
                                                  prof.exp.fem.1st == 0 & idprof.exp.nogen.1st == 3 ~ "Male Turkish Non Religious",
                                                  prof.exp.fem.1st == 1 & idprof.exp.nogen.1st == 4 ~ "Female FSU Muslim",
                                                  prof.exp.fem.1st == 0 & idprof.exp.nogen.1st == 4 ~ "Male FSU Muslim",
                                                  prof.exp.fem.1st == 1 & idprof.exp.nogen.1st == 5 ~ "Female FSU Christian",
                                                  prof.exp.fem.1st == 0 & idprof.exp.nogen.1st == 5 ~ "Male FSU Christian",
                                                  prof.exp.fem.1st == 1 & idprof.exp.nogen.1st == 6 ~ "Female FSU Non Religious",
                                                  prof.exp.fem.1st == 0 & idprof.exp.nogen.1st == 6 ~ "Male FSU Non Religious",
                                                  prof.exp.fem.1st == 1 & idprof.exp.nogen.1st == 7 ~ "Female Other Muslim",
                                                  prof.exp.fem.1st == 0 & idprof.exp.nogen.1st == 7 ~ "Male Other Muslim",
                                                  prof.exp.fem.1st == 1 & idprof.exp.nogen.1st == 8 ~ "Female Other Christian",
                                                  prof.exp.fem.1st == 0 & idprof.exp.nogen.1st == 8 ~ "Male Other Christian",
                                                  prof.exp.fem.1st == 1 & idprof.exp.nogen.1st == 9 ~ "Female Other Non Religious",
                                                  prof.exp.fem.1st == 0 & idprof.exp.nogen.1st == 9 ~ "Male Other Non Religious",
                                                  prof.exp.fem.1st == 1 & idprof.exp.nogen.1st == 10 ~ "Female German Muslim",
                                                  prof.exp.fem.1st == 0 & idprof.exp.nogen.1st == 10 ~ "Male German Muslim",
                                                  prof.exp.fem.1st == 1 & idprof.exp.nogen.1st == 11 ~ "Female German Christian",
                                                  prof.exp.fem.1st == 0 & idprof.exp.nogen.1st == 11 ~ "Male German Christian",
                                                  prof.exp.fem.1st == 1 & idprof.exp.nogen.1st == 12 ~ "Female German Non Religious",
                                                  prof.exp.fem.1st == 0 & idprof.exp.nogen.1st == 12 ~ "Male German Non Religious"))

DE <- DE %>% mutate(idprof.exp.2nd = case_when(prof.exp.fem.2nd == 1 & idprof.exp.nogen.2nd == 1 ~ "Female Turkish Muslim",
                                                  prof.exp.fem.2nd == 0 & idprof.exp.nogen.2nd == 1 ~ "Male Turkish Muslim",
                                                  prof.exp.fem.2nd == 1 & idprof.exp.nogen.2nd == 2 ~ "Female Turkish Christian",
                                                  prof.exp.fem.2nd == 0 & idprof.exp.nogen.2nd == 2 ~ "Male Turkish Christian",
                                                  prof.exp.fem.2nd == 1 & idprof.exp.nogen.2nd == 3 ~ "Female Turkish Non Religious",
                                                  prof.exp.fem.2nd == 0 & idprof.exp.nogen.2nd == 3 ~ "Male Turkish Non Religious",
                                                  prof.exp.fem.2nd == 1 & idprof.exp.nogen.2nd == 4 ~ "Female FSU Muslim",
                                                  prof.exp.fem.2nd == 0 & idprof.exp.nogen.2nd == 4 ~ "Male FSU Muslim",
                                                  prof.exp.fem.2nd == 1 & idprof.exp.nogen.2nd == 5 ~ "Female FSU Christian",
                                                  prof.exp.fem.2nd == 0 & idprof.exp.nogen.2nd == 5 ~ "Male FSU Christian",
                                                  prof.exp.fem.2nd == 1 & idprof.exp.nogen.2nd == 6 ~ "Female FSU Non Religious",
                                                  prof.exp.fem.2nd == 0 & idprof.exp.nogen.2nd == 6 ~ "Male FSU Non Religious",
                                                  prof.exp.fem.2nd == 1 & idprof.exp.nogen.2nd == 7 ~ "Female Other Muslim",
                                                  prof.exp.fem.2nd == 0 & idprof.exp.nogen.2nd == 7 ~ "Male Other Muslim",
                                                  prof.exp.fem.2nd == 1 & idprof.exp.nogen.2nd == 8 ~ "Female Other Christian",
                                                  prof.exp.fem.2nd == 0 & idprof.exp.nogen.2nd == 8 ~ "Male Other Christian",
                                                  prof.exp.fem.2nd == 1 & idprof.exp.nogen.2nd == 9 ~ "Female Other Non Religious",
                                                  prof.exp.fem.2nd == 0 & idprof.exp.nogen.2nd == 9 ~ "Male Other Non Religious",
                                                  prof.exp.fem.2nd == 1 & idprof.exp.nogen.2nd == 10 ~ "Female German Muslim",
                                                  prof.exp.fem.2nd == 0 & idprof.exp.nogen.2nd == 10 ~ "Male German Muslim",
                                                  prof.exp.fem.2nd == 1 & idprof.exp.nogen.2nd == 11 ~ "Female German Christian",
                                                  prof.exp.fem.2nd == 0 & idprof.exp.nogen.2nd == 11 ~ "Male German Christian",
                                                  prof.exp.fem.2nd == 1 & idprof.exp.nogen.2nd == 12 ~ "Female German Non Religious",
                                                  prof.exp.fem.2nd == 0 & idprof.exp.nogen.2nd == 12 ~ "Male German Non Religious"))

#1st
#prof.exp.ile religion
DE <- DE %>% mutate(prof.exp.Mu.1st = case_when(idprof.exp.1st == "Female Turkish Muslim" ~ 1,
                                                  idprof.exp.1st == "Male Turkish Muslim" ~ 1,
                                                  idprof.exp.1st == "Female Turkish Christian" ~ 0,
                                                  idprof.exp.1st == "Male Turkish Christian" ~ 0,
                                                  idprof.exp.1st == "Female Turkish Non Religious" ~ 0,
                                                  idprof.exp.1st == "Male Turkish Non Religious" ~ 0,
                                                  
                                                  idprof.exp.1st == "Female FSU Muslim" ~ 1,
                                                  idprof.exp.1st == "Male FSU Muslim" ~ 1,
                                                  idprof.exp.1st == "Female FSU Christian" ~ 0,
                                                  idprof.exp.1st == "Male FSU Christian" ~ 0,
                                                  idprof.exp.1st == "Female FSU Non Religious" ~ 0,
                                                  idprof.exp.1st == "Male FSU Non Religious" ~ 0,
                                                  
                                                  idprof.exp.1st == "Female Other Muslim" ~ 1,
                                                  idprof.exp.1st == "Male Other Muslim" ~ 1,
                                                  idprof.exp.1st == "Female Other Christian" ~ 0,
                                                  idprof.exp.1st == "Male Other Christian" ~ 0,
                                                  idprof.exp.1st == "Female Other Non Religious" ~ 0,
                                                  idprof.exp.1st == "Male Other Non Religious" ~ 0,
                                                  
                                                  idprof.exp.1st == "Female German Muslim" ~ 1,
                                                  idprof.exp.1st == "Male German Muslim" ~ 1,
                                                  idprof.exp.1st == "Female German Christian" ~ 0,
                                                  idprof.exp.1st == "Male German Christian" ~ 0,
                                                  idprof.exp.1st == "Female German Non Religious" ~ 0,
                                                  idprof.exp.1st == "Male German Non Religious" ~ 0))

DE <- DE %>% mutate(prof.exp.Chr.1st = case_when(idprof.exp.1st == "Female Turkish Muslim" ~ 0,
                                                   idprof.exp.1st == "Male Turkish Muslim" ~ 0,
                                                   idprof.exp.1st == "Female Turkish Christian" ~ 1,
                                                   idprof.exp.1st == "Male Turkish Christian" ~ 1,
                                                   idprof.exp.1st == "Female Turkish Non Religious" ~ 0,
                                                   idprof.exp.1st == "Male Turkish Non Religious" ~ 0,
                                                   
                                                   idprof.exp.1st == "Female FSU Muslim" ~ 0,
                                                   idprof.exp.1st == "Male FSU Muslim" ~ 0,
                                                   idprof.exp.1st == "Female FSU Christian" ~ 1,
                                                   idprof.exp.1st == "Male FSU Christian" ~ 1,
                                                   idprof.exp.1st == "Female FSU Non Religious" ~ 0,
                                                   idprof.exp.1st == "Male FSU Non Religious" ~ 0,
                                                   
                                                   idprof.exp.1st == "Female Other Muslim" ~ 0,
                                                   idprof.exp.1st == "Male Other Muslim" ~ 0,
                                                   idprof.exp.1st == "Female Other Christian" ~ 1,
                                                   idprof.exp.1st == "Male Other Christian" ~ 1,
                                                   idprof.exp.1st == "Female Other Non Religious" ~ 0,
                                                   idprof.exp.1st == "Male Other Non Religious" ~ 0,
                                                   
                                                   idprof.exp.1st == "Female German Muslim" ~ 0,
                                                   idprof.exp.1st == "Male German Muslim" ~ 0,
                                                   idprof.exp.1st == "Female German Christian" ~ 1,
                                                   idprof.exp.1st == "Male German Christian" ~ 1,
                                                   idprof.exp.1st == "Female German Non Religious" ~ 0,
                                                   idprof.exp.1st == "Male German Non Religious" ~ 0))

DE <- DE %>% mutate(prof.exp.No.1st = case_when(idprof.exp.1st == "Female Turkish Muslim" ~ 0,
                                                  idprof.exp.1st == "Male Turkish Muslim" ~ 0,
                                                  idprof.exp.1st == "Female Turkish Christian" ~ 0,
                                                  idprof.exp.1st == "Male Turkish Christian" ~ 0,
                                                  idprof.exp.1st == "Female Turkish Non Religious" ~ 1,
                                                  idprof.exp.1st == "Male Turkish Non Religious" ~ 1,
                                                  
                                                  idprof.exp.1st == "Female FSU Muslim" ~ 0,
                                                  idprof.exp.1st == "Male FSU Muslim" ~ 0,
                                                  idprof.exp.1st == "Female FSU Christian" ~ 0,
                                                  idprof.exp.1st == "Male FSU Christian" ~ 0,
                                                  idprof.exp.1st == "Female FSU Non Religious" ~ 1,
                                                  idprof.exp.1st == "Male FSU Non Religious" ~ 1,
                                                  
                                                  idprof.exp.1st == "Female Other Muslim" ~ 0,
                                                  idprof.exp.1st == "Male Other Muslim" ~ 0,
                                                  idprof.exp.1st == "Female Other Christian" ~ 0,
                                                  idprof.exp.1st == "Male Other Christian" ~ 0,
                                                  idprof.exp.1st == "Female Other Non Religious" ~ 1,
                                                  idprof.exp.1st == "Male Other Non Religious" ~ 1,
                                                  
                                                  idprof.exp.1st == "Female German Muslim" ~ 0,
                                                  idprof.exp.1st == "Male German Muslim" ~ 0,
                                                  idprof.exp.1st == "Female German Christian" ~ 0,
                                                  idprof.exp.1st == "Male German Christian" ~ 0,
                                                  idprof.exp.1st == "Female German Non Religious" ~ 1,
                                                  idprof.exp.1st == "Male German Non Religious" ~ 1))

#2nd
#prof.exp.ile religion
DE <- DE %>% mutate(prof.exp.Mu.2nd = case_when(idprof.exp.2nd == "Female Turkish Muslim" ~ 1,
                                                  idprof.exp.2nd == "Male Turkish Muslim" ~ 1,
                                                  idprof.exp.2nd == "Female Turkish Christian" ~ 0,
                                                  idprof.exp.2nd == "Male Turkish Christian" ~ 0,
                                                  idprof.exp.2nd == "Female Turkish Non Religious" ~ 0,
                                                  idprof.exp.2nd == "Male Turkish Non Religious" ~ 0,
                                                  
                                                  idprof.exp.2nd == "Female FSU Muslim" ~ 1,
                                                  idprof.exp.2nd == "Male FSU Muslim" ~ 1,
                                                  idprof.exp.2nd == "Female FSU Christian" ~ 0,
                                                  idprof.exp.2nd == "Male FSU Christian" ~ 0,
                                                  idprof.exp.2nd == "Female FSU Non Religious" ~ 0,
                                                  idprof.exp.2nd == "Male FSU Non Religious" ~ 0,
                                                  
                                                  idprof.exp.2nd == "Female Other Muslim" ~ 1,
                                                  idprof.exp.2nd == "Male Other Muslim" ~ 1,
                                                  idprof.exp.2nd == "Female Other Christian" ~ 0,
                                                  idprof.exp.2nd == "Male Other Christian" ~ 0,
                                                  idprof.exp.2nd == "Female Other Non Religious" ~ 0,
                                                  idprof.exp.2nd == "Male Other Non Religious" ~ 0,
                                                  
                                                  idprof.exp.2nd == "Female German Muslim" ~ 1,
                                                  idprof.exp.2nd == "Male German Muslim" ~ 1,
                                                  idprof.exp.2nd == "Female German Christian" ~ 0,
                                                  idprof.exp.2nd == "Male German Christian" ~ 0,
                                                  idprof.exp.2nd == "Female German Non Religious" ~ 0,
                                                  idprof.exp.2nd == "Male German Non Religious" ~ 0))

DE <- DE %>% mutate(prof.exp.Chr.2nd = case_when(idprof.exp.2nd == "Female Turkish Muslim" ~ 0,
                                                   idprof.exp.2nd == "Male Turkish Muslim" ~ 0,
                                                   idprof.exp.2nd == "Female Turkish Christian" ~ 1,
                                                   idprof.exp.2nd == "Male Turkish Christian" ~ 1,
                                                   idprof.exp.2nd == "Female Turkish Non Religious" ~ 0,
                                                   idprof.exp.2nd == "Male Turkish Non Religious" ~ 0,
                                                   
                                                   idprof.exp.2nd == "Female FSU Muslim" ~ 0,
                                                   idprof.exp.2nd == "Male FSU Muslim" ~ 0,
                                                   idprof.exp.2nd == "Female FSU Christian" ~ 1,
                                                   idprof.exp.2nd == "Male FSU Christian" ~ 1,
                                                   idprof.exp.2nd == "Female FSU Non Religious" ~ 0,
                                                   idprof.exp.2nd == "Male FSU Non Religious" ~ 0,
                                                   
                                                   idprof.exp.2nd == "Female Other Muslim" ~ 0,
                                                   idprof.exp.2nd == "Male Other Muslim" ~ 0,
                                                   idprof.exp.2nd == "Female Other Christian" ~ 1,
                                                   idprof.exp.2nd == "Male Other Christian" ~ 1,
                                                   idprof.exp.2nd == "Female Other Non Religious" ~ 0,
                                                   idprof.exp.2nd == "Male Other Non Religious" ~ 0,
                                                   
                                                   idprof.exp.2nd == "Female German Muslim" ~ 0,
                                                   idprof.exp.2nd == "Male German Muslim" ~ 0,
                                                   idprof.exp.2nd == "Female German Christian" ~ 1,
                                                   idprof.exp.2nd == "Male German Christian" ~ 1,
                                                   idprof.exp.2nd == "Female German Non Religious" ~ 0,
                                                   idprof.exp.2nd == "Male German Non Religious" ~ 0))

DE <- DE %>% mutate(prof.exp.No.2nd = case_when(idprof.exp.2nd == "Female Turkish Muslim" ~ 0,
                                                  idprof.exp.2nd == "Male Turkish Muslim" ~ 0,
                                                  idprof.exp.2nd == "Female Turkish Christian" ~ 0,
                                                  idprof.exp.2nd == "Male Turkish Christian" ~ 0,
                                                  idprof.exp.2nd == "Female Turkish Non Religious" ~ 1,
                                                  idprof.exp.2nd == "Male Turkish Non Religious" ~ 1,
                                                  
                                                  idprof.exp.2nd == "Female FSU Muslim" ~ 0,
                                                  idprof.exp.2nd == "Male FSU Muslim" ~ 0,
                                                  idprof.exp.2nd == "Female FSU Christian" ~ 0,
                                                  idprof.exp.2nd == "Male FSU Christian" ~ 0,
                                                  idprof.exp.2nd == "Female FSU Non Religious" ~ 1,
                                                  idprof.exp.2nd == "Male FSU Non Religious" ~ 1,
                                                  
                                                  idprof.exp.2nd == "Female Other Muslim" ~ 0,
                                                  idprof.exp.2nd == "Male Other Muslim" ~ 0,
                                                  idprof.exp.2nd == "Female Other Christian" ~ 0,
                                                  idprof.exp.2nd == "Male Other Christian" ~ 0,
                                                  idprof.exp.2nd == "Female Other Non Religious" ~ 1,
                                                  idprof.exp.2nd == "Male Other Non Religious" ~ 1,
                                                  
                                                  idprof.exp.2nd == "Female German Muslim" ~ 0,
                                                  idprof.exp.2nd == "Male German Muslim" ~ 0,
                                                  idprof.exp.2nd == "Female German Christian" ~ 0,
                                                  idprof.exp.2nd == "Male German Christian" ~ 0,
                                                  idprof.exp.2nd == "Female German Non Religious" ~ 1,
                                                  idprof.exp.2nd == "Male German Non Religious" ~ 1))

#NL
#profile gender
NL$idprof.exp.gen.1st <- NL$V10_1
NL$idprof.exp.gen.2nd <- NL$V10_2

NL <- NL %>% mutate(prof.exp.fem.1st = case_when(idprof.exp.gen.1st == 1  ~ 1,
                                                   idprof.exp.gen.1st == 2  ~ 1,
                                                   idprof.exp.gen.1st == 3  ~ 1,
                                                   idprof.exp.gen.1st == 4  ~ 1,
                                                   idprof.exp.gen.1st == 5  ~ 1,
                                                   idprof.exp.gen.1st == 6  ~ 1,
                                                   idprof.exp.gen.1st == 7  ~ 1,
                                                   idprof.exp.gen.1st == 8  ~ 1,
                                                   idprof.exp.gen.1st == 9  ~ 1,
                                                   idprof.exp.gen.1st == 10  ~ 0,
                                                   idprof.exp.gen.1st == 11  ~ 0,
                                                   idprof.exp.gen.1st == 12  ~ 0,
                                                   idprof.exp.gen.1st == 13  ~ 0,
                                                   idprof.exp.gen.1st == 14  ~ 0,
                                                   idprof.exp.gen.1st == 15  ~ 0,
                                                   idprof.exp.gen.1st == 16  ~ 0,
                                                   idprof.exp.gen.1st == 17  ~ 0,
                                                   idprof.exp.gen.1st == 18  ~ 0,
                                                   idprof.exp.gen.1st == 19  ~ 1,
                                                   idprof.exp.gen.1st == 20  ~ 1,
                                                   idprof.exp.gen.1st == 21  ~ 1,
                                                   idprof.exp.gen.1st == 22  ~ 1,
                                                   idprof.exp.gen.1st == 23  ~ 1,
                                                   idprof.exp.gen.1st == 24  ~ 1,
                                                   idprof.exp.gen.1st == 25  ~ 1,
                                                   idprof.exp.gen.1st == 26  ~ 1,
                                                   idprof.exp.gen.1st == 27  ~ 0,
                                                   idprof.exp.gen.1st == 28  ~ 0,
                                                   idprof.exp.gen.1st == 29  ~ 0,
                                                   idprof.exp.gen.1st == 30  ~ 0,
                                                   idprof.exp.gen.1st == 31  ~ 0,
                                                   idprof.exp.gen.1st == 32  ~ 0,
                                                   idprof.exp.gen.1st == 33  ~ 0,
                                                   idprof.exp.gen.1st == 34  ~ 0,
                                                   idprof.exp.gen.1st == 35  ~ 1,
                                                   idprof.exp.gen.1st == 36  ~ 1,
                                                   idprof.exp.gen.1st == 37  ~ 1,
                                                   idprof.exp.gen.1st == 38  ~ 1,
                                                   idprof.exp.gen.1st == 39  ~ 1,
                                                   idprof.exp.gen.1st == 40  ~ 1,
                                                   idprof.exp.gen.1st == 41  ~ 1,
                                                   idprof.exp.gen.1st == 42  ~ 1,
                                                   idprof.exp.gen.1st == 43  ~ 1,
                                                   idprof.exp.gen.1st == 44  ~ 1,
                                                   idprof.exp.gen.1st == 45  ~ 0,
                                                   idprof.exp.gen.1st == 46  ~ 0,
                                                   idprof.exp.gen.1st == 47  ~ 0,
                                                   idprof.exp.gen.1st == 48  ~ 0,
                                                   idprof.exp.gen.1st == 49  ~ 0,
                                                   idprof.exp.gen.1st == 50  ~ 0,
                                                   idprof.exp.gen.1st == 51  ~ 0,
                                                   idprof.exp.gen.1st == 52  ~ 0,
                                                   idprof.exp.gen.1st == 53  ~ 0,
                                                   idprof.exp.gen.1st == 54  ~ 0,
                                                   idprof.exp.gen.1st == 55  ~ 1,
                                                   idprof.exp.gen.1st == 56  ~ 1,
                                                   idprof.exp.gen.1st == 57  ~ 1,
                                                   idprof.exp.gen.1st == 58  ~ 1,
                                                   idprof.exp.gen.1st == 59  ~ 1,
                                                   idprof.exp.gen.1st == 60  ~ 1,
                                                   idprof.exp.gen.1st == 61  ~ 1,
                                                   idprof.exp.gen.1st == 62  ~ 1,
                                                   idprof.exp.gen.1st == 63  ~ 1,
                                                   idprof.exp.gen.1st == 64  ~ 0,
                                                   idprof.exp.gen.1st == 65  ~ 0,
                                                   idprof.exp.gen.1st == 66  ~ 0,
                                                   idprof.exp.gen.1st == 67  ~ 0,
                                                   idprof.exp.gen.1st == 68  ~ 0,
                                                   idprof.exp.gen.1st == 69  ~ 0,
                                                   idprof.exp.gen.1st == 70  ~ 0,
                                                   idprof.exp.gen.1st == 71  ~ 0,
                                                   idprof.exp.gen.1st == 72  ~ 0,
                                                   idprof.exp.gen.1st == 73  ~ 0,
                                                   idprof.exp.gen.1st == 74  ~ 0,
                                                   idprof.exp.gen.1st == 75  ~ 0,
                                                   idprof.exp.gen.1st == 76  ~ 1,
                                                   idprof.exp.gen.1st == 77  ~ 1,
                                                   idprof.exp.gen.1st == 78  ~ 1,
                                                   idprof.exp.gen.1st == 79  ~ 1,
                                                   idprof.exp.gen.1st == 80  ~ 1))

NL <- NL %>% mutate(prof.exp.fem.2nd = case_when(idprof.exp.gen.2nd == 1  ~ 1,
                                                   idprof.exp.gen.2nd == 2  ~ 1,
                                                   idprof.exp.gen.2nd == 3  ~ 1,
                                                   idprof.exp.gen.2nd == 4  ~ 1,
                                                   idprof.exp.gen.2nd == 5  ~ 1,
                                                   idprof.exp.gen.2nd == 6  ~ 1,
                                                   idprof.exp.gen.2nd == 7  ~ 1,
                                                   idprof.exp.gen.2nd == 8  ~ 1,
                                                   idprof.exp.gen.2nd == 9  ~ 1,
                                                   idprof.exp.gen.2nd == 10  ~ 0,
                                                   idprof.exp.gen.2nd == 11  ~ 0,
                                                   idprof.exp.gen.2nd == 12  ~ 0,
                                                   idprof.exp.gen.2nd == 13  ~ 0,
                                                   idprof.exp.gen.2nd == 14  ~ 0,
                                                   idprof.exp.gen.2nd == 15  ~ 0,
                                                   idprof.exp.gen.2nd == 16  ~ 0,
                                                   idprof.exp.gen.2nd == 17  ~ 0,
                                                   idprof.exp.gen.2nd == 18  ~ 0,
                                                   idprof.exp.gen.2nd == 19  ~ 1,
                                                   idprof.exp.gen.2nd == 20  ~ 1,
                                                   idprof.exp.gen.2nd == 21  ~ 1,
                                                   idprof.exp.gen.2nd == 22  ~ 1,
                                                   idprof.exp.gen.2nd == 23  ~ 1,
                                                   idprof.exp.gen.2nd == 24  ~ 1,
                                                   idprof.exp.gen.2nd == 25  ~ 1,
                                                   idprof.exp.gen.2nd == 26  ~ 1,
                                                   idprof.exp.gen.2nd == 27  ~ 0,
                                                   idprof.exp.gen.2nd == 28  ~ 0,
                                                   idprof.exp.gen.2nd == 29  ~ 0,
                                                   idprof.exp.gen.2nd == 30  ~ 0,
                                                   idprof.exp.gen.2nd == 31  ~ 0,
                                                   idprof.exp.gen.2nd == 32  ~ 0,
                                                   idprof.exp.gen.2nd == 33  ~ 0,
                                                   idprof.exp.gen.2nd == 34  ~ 0,
                                                   idprof.exp.gen.2nd == 35  ~ 1,
                                                   idprof.exp.gen.2nd == 36  ~ 1,
                                                   idprof.exp.gen.2nd == 37  ~ 1,
                                                   idprof.exp.gen.2nd == 38  ~ 1,
                                                   idprof.exp.gen.2nd == 39  ~ 1,
                                                   idprof.exp.gen.2nd == 40  ~ 1,
                                                   idprof.exp.gen.2nd == 41  ~ 1,
                                                   idprof.exp.gen.2nd == 42  ~ 1,
                                                   idprof.exp.gen.2nd == 43  ~ 1,
                                                   idprof.exp.gen.2nd == 44  ~ 1,
                                                   idprof.exp.gen.2nd == 45  ~ 0,
                                                   idprof.exp.gen.2nd == 46  ~ 0,
                                                   idprof.exp.gen.2nd == 47  ~ 0,
                                                   idprof.exp.gen.2nd == 48  ~ 0,
                                                   idprof.exp.gen.2nd == 49  ~ 0,
                                                   idprof.exp.gen.2nd == 50  ~ 0,
                                                   idprof.exp.gen.2nd == 51  ~ 0,
                                                   idprof.exp.gen.2nd == 52  ~ 0,
                                                   idprof.exp.gen.2nd == 53  ~ 0,
                                                   idprof.exp.gen.2nd == 54  ~ 0,
                                                   idprof.exp.gen.2nd == 55  ~ 1,
                                                   idprof.exp.gen.2nd == 56  ~ 1,
                                                   idprof.exp.gen.2nd == 57  ~ 1,
                                                   idprof.exp.gen.2nd == 58  ~ 1,
                                                   idprof.exp.gen.2nd == 59  ~ 1,
                                                   idprof.exp.gen.2nd == 60  ~ 1,
                                                   idprof.exp.gen.2nd == 61  ~ 1,
                                                   idprof.exp.gen.2nd == 62  ~ 1,
                                                   idprof.exp.gen.2nd == 63  ~ 1,
                                                   idprof.exp.gen.2nd == 64  ~ 0,
                                                   idprof.exp.gen.2nd == 65  ~ 0,
                                                   idprof.exp.gen.2nd == 66  ~ 0,
                                                   idprof.exp.gen.2nd == 67  ~ 0,
                                                   idprof.exp.gen.2nd == 68  ~ 0,
                                                   idprof.exp.gen.2nd == 69  ~ 0,
                                                   idprof.exp.gen.2nd == 70  ~ 0,
                                                   idprof.exp.gen.2nd == 71  ~ 0,
                                                   idprof.exp.gen.2nd == 72  ~ 0,
                                                   idprof.exp.gen.2nd == 73  ~ 0,
                                                   idprof.exp.gen.2nd == 74  ~ 0,
                                                   idprof.exp.gen.2nd == 75  ~ 0,
                                                   idprof.exp.gen.2nd == 76  ~ 1,
                                                   idprof.exp.gen.2nd == 77  ~ 1,
                                                   idprof.exp.gen.2nd == 78  ~ 1,
                                                   idprof.exp.gen.2nd == 79  ~ 1,
                                                   idprof.exp.gen.2nd == 80  ~ 1))

#idprof.exp.nogen
NL$idprof.exp.nogen.1st <- NL$V40_1
NL$idprof.exp.nogen.2nd <- NL$V40_2

NL <- NL %>% mutate(idprof.exp.1st = case_when(prof.exp.fem.1st == 1 & idprof.exp.nogen.1st == 1 ~ "Female Turkish Muslim",
                                                  prof.exp.fem.1st == 0 & idprof.exp.nogen.1st == 1 ~ "Male Turkish Muslim",
                                                  prof.exp.fem.1st == 1 & idprof.exp.nogen.1st == 2 ~ "Female Turkish Christian",
                                                  prof.exp.fem.1st == 0 & idprof.exp.nogen.1st == 2 ~ "Male Turkish Christian",
                                                  prof.exp.fem.1st == 1 & idprof.exp.nogen.1st == 3 ~ "Female Turkish Non Religious",
                                                  prof.exp.fem.1st == 0 & idprof.exp.nogen.1st == 3 ~ "Male Turkish Non Religious",
                                                  prof.exp.fem.1st == 1 & idprof.exp.nogen.1st == 4 ~ "Female Moroccan Muslim",
                                                  prof.exp.fem.1st == 0 & idprof.exp.nogen.1st == 4 ~ "Male Moroccan Muslim",
                                                  prof.exp.fem.1st == 1 & idprof.exp.nogen.1st == 5 ~ "Female Moroccan Christian",
                                                  prof.exp.fem.1st == 0 & idprof.exp.nogen.1st == 5 ~ "Male Moroccan Christian",
                                                  prof.exp.fem.1st == 1 & idprof.exp.nogen.1st == 6 ~ "Female Moroccan Non Religious",
                                                  prof.exp.fem.1st == 0 & idprof.exp.nogen.1st == 6 ~ "Male Moroccan Non Religious",
                                                  prof.exp.fem.1st == 1 & idprof.exp.nogen.1st == 7 ~ "Female Surinamese Muslim",
                                                  prof.exp.fem.1st == 0 & idprof.exp.nogen.1st == 7 ~ "Male Surinamese Muslim",
                                                  prof.exp.fem.1st == 1 & idprof.exp.nogen.1st == 8 ~ "Female Surinamese Christian",
                                                  prof.exp.fem.1st == 0 & idprof.exp.nogen.1st == 8 ~ "Male Surinamese Christian",
                                                  prof.exp.fem.1st == 1 & idprof.exp.nogen.1st == 9 ~ "Female Surinamese Non Religious",
                                                  prof.exp.fem.1st == 0 & idprof.exp.nogen.1st == 9 ~ "Male Surinamese Non Religious",
                                                  prof.exp.fem.1st == 1 & idprof.exp.nogen.1st == 10 ~ "Female Dutch Muslim",
                                                  prof.exp.fem.1st == 0 & idprof.exp.nogen.1st == 10 ~ "Male Dutch Muslim",
                                                  prof.exp.fem.1st == 1 & idprof.exp.nogen.1st == 11 ~ "Female Dutch Christian",
                                                  prof.exp.fem.1st == 0 & idprof.exp.nogen.1st == 11 ~ "Male Dutch Christian",
                                                  prof.exp.fem.1st == 1 & idprof.exp.nogen.1st == 12 ~ "Female Dutch Non Religious",
                                                  prof.exp.fem.1st == 0 & idprof.exp.nogen.1st == 12 ~ "Male Dutch Non Religious"))

NL <- NL %>% mutate(idprof.exp.2nd = case_when(prof.exp.fem.2nd == 1 & idprof.exp.nogen.2nd == 1 ~ "Female Turkish Muslim",
                                                  prof.exp.fem.2nd == 0 & idprof.exp.nogen.2nd == 1 ~ "Male Turkish Muslim",
                                                  prof.exp.fem.2nd == 1 & idprof.exp.nogen.2nd == 2 ~ "Female Turkish Christian",
                                                  prof.exp.fem.2nd == 0 & idprof.exp.nogen.2nd == 2 ~ "Male Turkish Christian",
                                                  prof.exp.fem.2nd == 1 & idprof.exp.nogen.2nd == 3 ~ "Female Turkish Non Religious",
                                                  prof.exp.fem.2nd == 0 & idprof.exp.nogen.2nd == 3 ~ "Male Turkish Non Religious",
                                                  prof.exp.fem.2nd == 1 & idprof.exp.nogen.2nd == 4 ~ "Female Moroccan Muslim",
                                                  prof.exp.fem.2nd == 0 & idprof.exp.nogen.2nd == 4 ~ "Male Moroccan Muslim",
                                                  prof.exp.fem.2nd == 1 & idprof.exp.nogen.2nd == 5 ~ "Female Moroccan Christian",
                                                  prof.exp.fem.2nd == 0 & idprof.exp.nogen.2nd == 5 ~ "Male Moroccan Christian",
                                                  prof.exp.fem.2nd == 1 & idprof.exp.nogen.2nd == 6 ~ "Female Moroccan Non Religious",
                                                  prof.exp.fem.2nd == 0 & idprof.exp.nogen.2nd == 6 ~ "Male Moroccan Non Religious",
                                                  prof.exp.fem.2nd == 1 & idprof.exp.nogen.2nd == 7 ~ "Female Surinamese Muslim",
                                                  prof.exp.fem.2nd == 0 & idprof.exp.nogen.2nd == 7 ~ "Male Surinamese Muslim",
                                                  prof.exp.fem.2nd == 1 & idprof.exp.nogen.2nd == 8 ~ "Female Surinamese Christian",
                                                  prof.exp.fem.2nd == 0 & idprof.exp.nogen.2nd == 8 ~ "Male Surinamese Christian",
                                                  prof.exp.fem.2nd == 1 & idprof.exp.nogen.2nd == 9 ~ "Female Surinamese Non Religious",
                                                  prof.exp.fem.2nd == 0 & idprof.exp.nogen.2nd == 9 ~ "Male Surinamese Non Religious",
                                                  prof.exp.fem.2nd == 1 & idprof.exp.nogen.2nd == 10 ~ "Female Dutch Muslim",
                                                  prof.exp.fem.2nd == 0 & idprof.exp.nogen.2nd == 10 ~ "Male Dutch Muslim",
                                                  prof.exp.fem.2nd == 1 & idprof.exp.nogen.2nd == 11 ~ "Female Dutch Christian",
                                                  prof.exp.fem.2nd == 0 & idprof.exp.nogen.2nd == 11 ~ "Male Dutch Christian",
                                                  prof.exp.fem.2nd == 1 & idprof.exp.nogen.2nd == 12 ~ "Female Dutch Non Religious",
                                                  prof.exp.fem.2nd == 0 & idprof.exp.nogen.2nd == 12 ~ "Male Dutch Non Religious"))

#1st
#prof.exp.ile religion
NL <- NL %>% mutate(prof.exp.Mu.1st = case_when(idprof.exp.1st == "Female Turkish Muslim" ~ 1,
                                                  idprof.exp.1st == "Male Turkish Muslim" ~ 1,
                                                  idprof.exp.1st == "Female Turkish Christian" ~ 0,
                                                  idprof.exp.1st == "Male Turkish Christian" ~ 0,
                                                  idprof.exp.1st == "Female Turkish Non Religious" ~ 0,
                                                  idprof.exp.1st == "Male Turkish Non Religious" ~ 0,
                                                  
                                                  idprof.exp.1st == "Female Moroccan Muslim" ~ 1,
                                                  idprof.exp.1st == "Male Moroccan Muslim" ~ 1,
                                                  idprof.exp.1st == "Female Moroccan Christian" ~ 0,
                                                  idprof.exp.1st == "Male Moroccan Christian" ~ 0,
                                                  idprof.exp.1st == "Female Moroccan Non Religious" ~ 0,
                                                  idprof.exp.1st == "Male Moroccan Non Religious" ~ 0,
                                                  
                                                  idprof.exp.1st == "Female Surinamese Muslim" ~ 1,
                                                  idprof.exp.1st == "Male Surinamese Muslim" ~ 1,
                                                  idprof.exp.1st == "Female Surinamese Christian" ~ 0,
                                                  idprof.exp.1st == "Male Surinamese Christian" ~ 0,
                                                  idprof.exp.1st == "Female Surinamese Non Religious" ~ 0,
                                                  idprof.exp.1st == "Male Surinamese Non Religious" ~ 0,
                                                  
                                                  idprof.exp.1st == "Female Dutch Muslim" ~ 1,
                                                  idprof.exp.1st == "Male Dutch Muslim" ~ 1,
                                                  idprof.exp.1st == "Female Dutch Christian" ~ 0,
                                                  idprof.exp.1st == "Male Dutch Christian" ~ 0,
                                                  idprof.exp.1st == "Female Dutch Non Religious" ~ 0,
                                                  idprof.exp.1st == "Male Dutch Non Religious" ~ 0))

NL <- NL %>% mutate(prof.exp.Chr.1st = case_when(idprof.exp.1st == "Female Turkish Muslim" ~ 0,
                                                   idprof.exp.1st == "Male Turkish Muslim" ~ 0,
                                                   idprof.exp.1st == "Female Turkish Christian" ~ 1,
                                                   idprof.exp.1st == "Male Turkish Christian" ~ 1,
                                                   idprof.exp.1st == "Female Turkish Non Religious" ~ 0,
                                                   idprof.exp.1st == "Male Turkish Non Religious" ~ 0,
                                                   
                                                   idprof.exp.1st == "Female Moroccan Muslim" ~ 0,
                                                   idprof.exp.1st == "Male Moroccan Muslim" ~ 0,
                                                   idprof.exp.1st == "Female Moroccan Christian" ~ 1,
                                                   idprof.exp.1st == "Male Moroccan Christian" ~ 1,
                                                   idprof.exp.1st == "Female Moroccan Non Religious" ~ 0,
                                                   idprof.exp.1st == "Male Moroccan Non Religious" ~ 0,
                                                   
                                                   idprof.exp.1st == "Female Surinamese Muslim" ~ 0,
                                                   idprof.exp.1st == "Male Surinamese Muslim" ~ 0,
                                                   idprof.exp.1st == "Female Surinamese Christian" ~ 1,
                                                   idprof.exp.1st == "Male Surinamese Christian" ~ 1,
                                                   idprof.exp.1st == "Female Surinamese Non Religious" ~ 0,
                                                   idprof.exp.1st == "Male Surinamese Non Religious" ~ 0,
                                                   
                                                   idprof.exp.1st == "Female Dutch Muslim" ~ 0,
                                                   idprof.exp.1st == "Male Dutch Muslim" ~ 0,
                                                   idprof.exp.1st == "Female Dutch Christian" ~ 1,
                                                   idprof.exp.1st == "Male Dutch Christian" ~ 1,
                                                   idprof.exp.1st == "Female Dutch Non Religious" ~ 0,
                                                   idprof.exp.1st == "Male Dutch Non Religious" ~ 0))

NL <- NL %>% mutate(prof.exp.No.1st = case_when(idprof.exp.1st == "Female Turkish Muslim" ~ 0,
                                                  idprof.exp.1st == "Male Turkish Muslim" ~ 0,
                                                  idprof.exp.1st == "Female Turkish Christian" ~ 0,
                                                  idprof.exp.1st == "Male Turkish Christian" ~ 0,
                                                  idprof.exp.1st == "Female Turkish Non Religious" ~ 1,
                                                  idprof.exp.1st == "Male Turkish Non Religious" ~ 1,
                                                  
                                                  idprof.exp.1st == "Female Moroccan Muslim" ~ 0,
                                                  idprof.exp.1st == "Male Moroccan Muslim" ~ 0,
                                                  idprof.exp.1st == "Female Moroccan Christian" ~ 0,
                                                  idprof.exp.1st == "Male Moroccan Christian" ~ 0,
                                                  idprof.exp.1st == "Female Moroccan Non Religious" ~ 1,
                                                  idprof.exp.1st == "Male Moroccan Non Religious" ~ 1,
                                                  
                                                  idprof.exp.1st == "Female Surinamese Muslim" ~ 0,
                                                  idprof.exp.1st == "Male Surinamese Muslim" ~ 0,
                                                  idprof.exp.1st == "Female Surinamese Christian" ~ 0,
                                                  idprof.exp.1st == "Male Surinamese Christian" ~ 0,
                                                  idprof.exp.1st == "Female Surinamese Non Religious" ~ 1,
                                                  idprof.exp.1st == "Male Surinamese Non Religious" ~ 1,
                                                  
                                                  idprof.exp.1st == "Female Dutch Muslim" ~ 0,
                                                  idprof.exp.1st == "Male Dutch Muslim" ~ 0,
                                                  idprof.exp.1st == "Female Dutch Christian" ~ 0,
                                                  idprof.exp.1st == "Male Dutch Christian" ~ 0,
                                                  idprof.exp.1st == "Female Dutch Non Religious" ~ 1,
                                                  idprof.exp.1st == "Male Dutch Non Religious" ~ 1))

#2nd
#prof.exp.ile religion
NL <- NL %>% mutate(prof.exp.Mu.2nd = case_when(idprof.exp.2nd == "Female Turkish Muslim" ~ 1,
                                                  idprof.exp.2nd == "Male Turkish Muslim" ~ 1,
                                                  idprof.exp.2nd == "Female Turkish Christian" ~ 0,
                                                  idprof.exp.2nd == "Male Turkish Christian" ~ 0,
                                                  idprof.exp.2nd == "Female Turkish Non Religious" ~ 0,
                                                  idprof.exp.2nd == "Male Turkish Non Religious" ~ 0,
                                                  
                                                  idprof.exp.2nd == "Female Moroccan Muslim" ~ 1,
                                                  idprof.exp.2nd == "Male Moroccan Muslim" ~ 1,
                                                  idprof.exp.2nd == "Female Moroccan Christian" ~ 0,
                                                  idprof.exp.2nd == "Male Moroccan Christian" ~ 0,
                                                  idprof.exp.2nd == "Female Moroccan Non Religious" ~ 0,
                                                  idprof.exp.2nd == "Male Moroccan Non Religious" ~ 0,
                                                  
                                                  idprof.exp.2nd == "Female Surinamese Muslim" ~ 1,
                                                  idprof.exp.2nd == "Male Surinamese Muslim" ~ 1,
                                                  idprof.exp.2nd == "Female Surinamese Christian" ~ 0,
                                                  idprof.exp.2nd == "Male Surinamese Christian" ~ 0,
                                                  idprof.exp.2nd == "Female Surinamese Non Religious" ~ 0,
                                                  idprof.exp.2nd == "Male Surinamese Non Religious" ~ 0,
                                                  
                                                  idprof.exp.2nd == "Female Dutch Muslim" ~ 1,
                                                  idprof.exp.2nd == "Male Dutch Muslim" ~ 1,
                                                  idprof.exp.2nd == "Female Dutch Christian" ~ 0,
                                                  idprof.exp.2nd == "Male Dutch Christian" ~ 0,
                                                  idprof.exp.2nd == "Female Dutch Non Religious" ~ 0,
                                                  idprof.exp.2nd == "Male Dutch Non Religious" ~ 0))

NL <- NL %>% mutate(prof.exp.Chr.2nd = case_when(idprof.exp.2nd == "Female Turkish Muslim" ~ 0,
                                                   idprof.exp.2nd == "Male Turkish Muslim" ~ 0,
                                                   idprof.exp.2nd == "Female Turkish Christian" ~ 1,
                                                   idprof.exp.2nd == "Male Turkish Christian" ~ 1,
                                                   idprof.exp.2nd == "Female Turkish Non Religious" ~ 0,
                                                   idprof.exp.2nd == "Male Turkish Non Religious" ~ 0,
                                                   
                                                   idprof.exp.2nd == "Female Moroccan Muslim" ~ 0,
                                                   idprof.exp.2nd == "Male Moroccan Muslim" ~ 0,
                                                   idprof.exp.2nd == "Female Moroccan Christian" ~ 1,
                                                   idprof.exp.2nd == "Male Moroccan Christian" ~ 1,
                                                   idprof.exp.2nd == "Female Moroccan Non Religious" ~ 0,
                                                   idprof.exp.2nd == "Male Moroccan Non Religious" ~ 0,
                                                   
                                                   idprof.exp.2nd == "Female Surinamese Muslim" ~ 0,
                                                   idprof.exp.2nd == "Male Surinamese Muslim" ~ 0,
                                                   idprof.exp.2nd == "Female Surinamese Christian" ~ 1,
                                                   idprof.exp.2nd == "Male Surinamese Christian" ~ 1,
                                                   idprof.exp.2nd == "Female Surinamese Non Religious" ~ 0,
                                                   idprof.exp.2nd == "Male Surinamese Non Religious" ~ 0,
                                                   
                                                   idprof.exp.2nd == "Female Dutch Muslim" ~ 0,
                                                   idprof.exp.2nd == "Male Dutch Muslim" ~ 0,
                                                   idprof.exp.2nd == "Female Dutch Christian" ~ 1,
                                                   idprof.exp.2nd == "Male Dutch Christian" ~ 1,
                                                   idprof.exp.2nd == "Female Dutch Non Religious" ~ 0,
                                                   idprof.exp.2nd == "Male Dutch Non Religious" ~ 0))

NL <- NL %>% mutate(prof.exp.No.2nd = case_when(idprof.exp.2nd == "Female Turkish Muslim" ~ 0,
                                                  idprof.exp.2nd == "Male Turkish Muslim" ~ 0,
                                                  idprof.exp.2nd == "Female Turkish Christian" ~ 0,
                                                  idprof.exp.2nd == "Male Turkish Christian" ~ 0,
                                                  idprof.exp.2nd == "Female Turkish Non Religious" ~ 1,
                                                  idprof.exp.2nd == "Male Turkish Non Religious" ~ 1,
                                                  
                                                  idprof.exp.2nd == "Female Moroccan Muslim" ~ 0,
                                                  idprof.exp.2nd == "Male Moroccan Muslim" ~ 0,
                                                  idprof.exp.2nd == "Female Moroccan Christian" ~ 0,
                                                  idprof.exp.2nd == "Male Moroccan Christian" ~ 0,
                                                  idprof.exp.2nd == "Female Moroccan Non Religious" ~ 1,
                                                  idprof.exp.2nd == "Male Moroccan Non Religious" ~ 1,
                                                  
                                                  idprof.exp.2nd == "Female Surinamese Muslim" ~ 0,
                                                  idprof.exp.2nd == "Male Surinamese Muslim" ~ 0,
                                                  idprof.exp.2nd == "Female Surinamese Christian" ~ 0,
                                                  idprof.exp.2nd == "Male Surinamese Christian" ~ 0,
                                                  idprof.exp.2nd == "Female Surinamese Non Religious" ~ 1,
                                                  idprof.exp.2nd == "Male Surinamese Non Religious" ~ 1,
                                                  
                                                  idprof.exp.2nd == "Female Dutch Muslim" ~ 0,
                                                  idprof.exp.2nd == "Male Dutch Muslim" ~ 0,
                                                  idprof.exp.2nd == "Female Dutch Christian" ~ 0,
                                                  idprof.exp.2nd == "Male Dutch Christian" ~ 0,
                                                  idprof.exp.2nd == "Female Dutch Non Religious" ~ 1,
                                                  idprof.exp.2nd == "Male Dutch Non Religious" ~ 1))

#1st
FR <- FR %>% mutate(prof.exp.Tur.1st = case_when(idprof.exp.1st == "Female Turkish Muslim" ~ 1,
                                                 idprof.exp.1st == "Male Turkish Muslim" ~ 1,
                                                 idprof.exp.1st == "Female Turkish Christian" ~ 1,
                                                 idprof.exp.1st == "Male Turkish Christian" ~ 1,
                                                 idprof.exp.1st == "Female Turkish Non Religious" ~ 1,
                                                 idprof.exp.1st == "Male Turkish Non Religious" ~ 1,
                                                 
                                                 idprof.exp.1st == "Female Maghrebi Muslim" ~ 0,
                                                 idprof.exp.1st == "Male Maghrebi Muslim" ~ 0,
                                                 idprof.exp.1st == "Female Maghrebi Christian" ~ 0,
                                                 idprof.exp.1st == "Male Maghrebi Christian" ~ 0,
                                                 idprof.exp.1st == "Female Maghrebi Non Religious" ~ 0,
                                                 idprof.exp.1st == "Male Maghrebi Non Religious" ~ 0,
                                                 
                                                 idprof.exp.1st == "Female SSA Muslim" ~ 0,
                                                 idprof.exp.1st == "Male SSA Muslim" ~ 0,
                                                 idprof.exp.1st == "Female SSA Christian" ~ 0,
                                                 idprof.exp.1st == "Male SSA Christian" ~ 0,
                                                 idprof.exp.1st == "Female SSA Non Religious" ~ 0,
                                                 idprof.exp.1st == "Male SSA Non Religious" ~ 0,
                                                 
                                                 idprof.exp.1st == "Female French Muslim" ~ 0,
                                                 idprof.exp.1st == "Male French Muslim" ~ 0,
                                                 idprof.exp.1st == "Female French Christian" ~ 0,
                                                 idprof.exp.1st == "Male French Christian" ~ 0,
                                                 idprof.exp.1st == "Female French Non Religious" ~ 0,
                                                 idprof.exp.1st == "Male French Non Religious" ~ 0))

FR <- FR %>% mutate(prof.exp.Mag.1st = case_when(idprof.exp.1st == "Female Turkish Muslim" ~ 0,
                                                 idprof.exp.1st == "Male Turkish Muslim" ~ 0,
                                                 idprof.exp.1st == "Female Turkish Christian" ~ 0,
                                                 idprof.exp.1st == "Male Turkish Christian" ~ 0,
                                                 idprof.exp.1st == "Female Turkish Non Religious" ~ 0,
                                                 idprof.exp.1st == "Male Turkish Non Religious" ~ 0,
                                                 
                                                 idprof.exp.1st == "Female Maghrebi Muslim" ~ 1,
                                                 idprof.exp.1st == "Male Maghrebi Muslim" ~ 1,
                                                 idprof.exp.1st == "Female Maghrebi Christian" ~ 1,
                                                 idprof.exp.1st == "Male Maghrebi Christian" ~ 1,
                                                 idprof.exp.1st == "Female Maghrebi Non Religious" ~ 1,
                                                 idprof.exp.1st == "Male Maghrebi Non Religious" ~ 1,
                                                 
                                                 idprof.exp.1st == "Female SSA Muslim" ~ 0,
                                                 idprof.exp.1st == "Male SSA Muslim" ~ 0,
                                                 idprof.exp.1st == "Female SSA Christian" ~ 0,
                                                 idprof.exp.1st == "Male SSA Christian" ~ 0,
                                                 idprof.exp.1st == "Female SSA Non Religious" ~ 0,
                                                 idprof.exp.1st == "Male SSA Non Religious" ~ 0,
                                                 
                                                 idprof.exp.1st == "Female French Muslim" ~ 0,
                                                 idprof.exp.1st == "Male French Muslim" ~ 0,
                                                 idprof.exp.1st == "Female French Christian" ~ 0,
                                                 idprof.exp.1st == "Male French Christian" ~ 0,
                                                 idprof.exp.1st == "Female French Non Religious" ~ 0,
                                                 idprof.exp.1st == "Male French Non Religious" ~ 0))

FR <- FR %>% mutate(prof.exp.SSA.1st = case_when(idprof.exp.1st == "Female Turkish Muslim" ~ 0,
                                                 idprof.exp.1st == "Male Turkish Muslim" ~ 0,
                                                 idprof.exp.1st == "Female Turkish Christian" ~ 0,
                                                 idprof.exp.1st == "Male Turkish Christian" ~ 0,
                                                 idprof.exp.1st == "Female Turkish Non Religious" ~ 0,
                                                 idprof.exp.1st == "Male Turkish Non Religious" ~ 0,
                                                 
                                                 idprof.exp.1st == "Female Maghrebi Muslim" ~ 0,
                                                 idprof.exp.1st == "Male Maghrebi Muslim" ~ 0,
                                                 idprof.exp.1st == "Female Maghrebi Christian" ~ 0,
                                                 idprof.exp.1st == "Male Maghrebi Christian" ~ 0,
                                                 idprof.exp.1st == "Female Maghrebi Non Religious" ~ 0,
                                                 idprof.exp.1st == "Male Maghrebi Non Religious" ~ 0,
                                                 
                                                 idprof.exp.1st == "Female SSA Muslim" ~ 1,
                                                 idprof.exp.1st == "Male SSA Muslim" ~ 1,
                                                 idprof.exp.1st == "Female SSA Christian" ~ 1,
                                                 idprof.exp.1st == "Male SSA Christian" ~ 1,
                                                 idprof.exp.1st == "Female SSA Non Religious" ~ 1,
                                                 idprof.exp.1st == "Male SSA Non Religious" ~ 1,
                                                 
                                                 idprof.exp.1st == "Female French Muslim" ~ 0,
                                                 idprof.exp.1st == "Male French Muslim" ~ 0,
                                                 idprof.exp.1st == "Female French Christian" ~ 0,
                                                 idprof.exp.1st == "Male French Christian" ~ 0,
                                                 idprof.exp.1st == "Female French Non Religious" ~ 0,
                                                 idprof.exp.1st == "Male French Non Religious" ~ 0))

FR <- FR %>% mutate(prof.exp.NoMig.1st = case_when(idprof.exp.1st == "Female Turkish Muslim" ~ 0,
                                                   idprof.exp.1st == "Male Turkish Muslim" ~ 0,
                                                   idprof.exp.1st == "Female Turkish Christian" ~ 0,
                                                   idprof.exp.1st == "Male Turkish Christian" ~ 0,
                                                   idprof.exp.1st == "Female Turkish Non Religious" ~ 0,
                                                   idprof.exp.1st == "Male Turkish Non Religious" ~ 0,
                                                   
                                                   idprof.exp.1st == "Female Maghrebi Muslim" ~ 0,
                                                   idprof.exp.1st == "Male Maghrebi Muslim" ~ 0,
                                                   idprof.exp.1st == "Female Maghrebi Christian" ~ 0,
                                                   idprof.exp.1st == "Male Maghrebi Christian" ~ 0,
                                                   idprof.exp.1st == "Female Maghrebi Non Religious" ~ 0,
                                                   idprof.exp.1st == "Male Maghrebi Non Religious" ~ 0,
                                                   
                                                   idprof.exp.1st == "Female SSA Muslim" ~ 0,
                                                   idprof.exp.1st == "Male SSA Muslim" ~ 0,
                                                   idprof.exp.1st == "Female SSA Christian" ~ 0,
                                                   idprof.exp.1st == "Male SSA Christian" ~ 0,
                                                   idprof.exp.1st == "Female SSA Non Religious" ~ 0,
                                                   idprof.exp.1st == "Male SSA Non Religious" ~ 0,
                                                   
                                                   idprof.exp.1st == "Female French Muslim" ~ 1,
                                                   idprof.exp.1st == "Male French Muslim" ~ 1,
                                                   idprof.exp.1st == "Female French Christian" ~ 1,
                                                   idprof.exp.1st == "Male French Christian" ~ 1,
                                                   idprof.exp.1st == "Female French Non Religious" ~ 1,
                                                   idprof.exp.1st == "Male French Non Religious" ~ 1))

#2nd
FR <- FR %>% mutate(prof.exp.Tur.2nd = case_when(idprof.exp.2nd == "Female Turkish Muslim" ~ 1,
                                                 idprof.exp.2nd == "Male Turkish Muslim" ~ 1,
                                                 idprof.exp.2nd == "Female Turkish Christian" ~ 1,
                                                 idprof.exp.2nd == "Male Turkish Christian" ~ 1,
                                                 idprof.exp.2nd == "Female Turkish Non Religious" ~ 1,
                                                 idprof.exp.2nd == "Male Turkish Non Religious" ~ 1,
                                                 
                                                 idprof.exp.2nd == "Female Maghrebi Muslim" ~ 0,
                                                 idprof.exp.2nd == "Male Maghrebi Muslim" ~ 0,
                                                 idprof.exp.2nd == "Female Maghrebi Christian" ~ 0,
                                                 idprof.exp.2nd == "Male Maghrebi Christian" ~ 0,
                                                 idprof.exp.2nd == "Female Maghrebi Non Religious" ~ 0,
                                                 idprof.exp.2nd == "Male Maghrebi Non Religious" ~ 0,
                                                 
                                                 idprof.exp.2nd == "Female SSA Muslim" ~ 0,
                                                 idprof.exp.2nd == "Male SSA Muslim" ~ 0,
                                                 idprof.exp.2nd == "Female SSA Christian" ~ 0,
                                                 idprof.exp.2nd == "Male SSA Christian" ~ 0,
                                                 idprof.exp.2nd == "Female SSA Non Religious" ~ 0,
                                                 idprof.exp.2nd == "Male SSA Non Religious" ~ 0,
                                                 
                                                 idprof.exp.2nd == "Female French Muslim" ~ 0,
                                                 idprof.exp.2nd == "Male French Muslim" ~ 0,
                                                 idprof.exp.2nd == "Female French Christian" ~ 0,
                                                 idprof.exp.2nd == "Male French Christian" ~ 0,
                                                 idprof.exp.2nd == "Female French Non Religious" ~ 0,
                                                 idprof.exp.2nd == "Male French Non Religious" ~ 0))

FR <- FR %>% mutate(prof.exp.Mag.2nd = case_when(idprof.exp.2nd == "Female Turkish Muslim" ~ 0,
                                                 idprof.exp.2nd == "Male Turkish Muslim" ~ 0,
                                                 idprof.exp.2nd == "Female Turkish Christian" ~ 0,
                                                 idprof.exp.2nd == "Male Turkish Christian" ~ 0,
                                                 idprof.exp.2nd == "Female Turkish Non Religious" ~ 0,
                                                 idprof.exp.2nd == "Male Turkish Non Religious" ~ 0,
                                                 
                                                 idprof.exp.2nd == "Female Maghrebi Muslim" ~ 1,
                                                 idprof.exp.2nd == "Male Maghrebi Muslim" ~ 1,
                                                 idprof.exp.2nd == "Female Maghrebi Christian" ~ 1,
                                                 idprof.exp.2nd == "Male Maghrebi Christian" ~ 1,
                                                 idprof.exp.2nd == "Female Maghrebi Non Religious" ~ 1,
                                                 idprof.exp.2nd == "Male Maghrebi Non Religious" ~ 1,
                                                 
                                                 idprof.exp.2nd == "Female SSA Muslim" ~ 0,
                                                 idprof.exp.2nd == "Male SSA Muslim" ~ 0,
                                                 idprof.exp.2nd == "Female SSA Christian" ~ 0,
                                                 idprof.exp.2nd == "Male SSA Christian" ~ 0,
                                                 idprof.exp.2nd == "Female SSA Non Religious" ~ 0,
                                                 idprof.exp.2nd == "Male SSA Non Religious" ~ 0,
                                                 
                                                 idprof.exp.2nd == "Female French Muslim" ~ 0,
                                                 idprof.exp.2nd == "Male French Muslim" ~ 0,
                                                 idprof.exp.2nd == "Female French Christian" ~ 0,
                                                 idprof.exp.2nd == "Male French Christian" ~ 0,
                                                 idprof.exp.2nd == "Female French Non Religious" ~ 0,
                                                 idprof.exp.2nd == "Male French Non Religious" ~ 0))

FR <- FR %>% mutate(prof.exp.SSA.2nd = case_when(idprof.exp.2nd == "Female Turkish Muslim" ~ 0,
                                                 idprof.exp.2nd == "Male Turkish Muslim" ~ 0,
                                                 idprof.exp.2nd == "Female Turkish Christian" ~ 0,
                                                 idprof.exp.2nd == "Male Turkish Christian" ~ 0,
                                                 idprof.exp.2nd == "Female Turkish Non Religious" ~ 0,
                                                 idprof.exp.2nd == "Male Turkish Non Religious" ~ 0,
                                                 
                                                 idprof.exp.2nd == "Female Maghrebi Muslim" ~ 0,
                                                 idprof.exp.2nd == "Male Maghrebi Muslim" ~ 0,
                                                 idprof.exp.2nd == "Female Maghrebi Christian" ~ 0,
                                                 idprof.exp.2nd == "Male Maghrebi Christian" ~ 0,
                                                 idprof.exp.2nd == "Female Maghrebi Non Religious" ~ 0,
                                                 idprof.exp.2nd == "Male Maghrebi Non Religious" ~ 0,
                                                 
                                                 idprof.exp.2nd == "Female SSA Muslim" ~ 1,
                                                 idprof.exp.2nd == "Male SSA Muslim" ~ 1,
                                                 idprof.exp.2nd == "Female SSA Christian" ~ 1,
                                                 idprof.exp.2nd == "Male SSA Christian" ~ 1,
                                                 idprof.exp.2nd == "Female SSA Non Religious" ~ 1,
                                                 idprof.exp.2nd == "Male SSA Non Religious" ~ 1,
                                                 
                                                 idprof.exp.2nd == "Female French Muslim" ~ 0,
                                                 idprof.exp.2nd == "Male French Muslim" ~ 0,
                                                 idprof.exp.2nd == "Female French Christian" ~ 0,
                                                 idprof.exp.2nd == "Male French Christian" ~ 0,
                                                 idprof.exp.2nd == "Female French Non Religious" ~ 0,
                                                 idprof.exp.2nd == "Male French Non Religious" ~ 0))

FR <- FR %>% mutate(prof.exp.NoMig.2nd = case_when(idprof.exp.2nd == "Female Turkish Muslim" ~ 0,
                                                   idprof.exp.2nd == "Male Turkish Muslim" ~ 0,
                                                   idprof.exp.2nd == "Female Turkish Christian" ~ 0,
                                                   idprof.exp.2nd == "Male Turkish Christian" ~ 0,
                                                   idprof.exp.2nd == "Female Turkish Non Religious" ~ 0,
                                                   idprof.exp.2nd == "Male Turkish Non Religious" ~ 0,
                                                   
                                                   idprof.exp.2nd == "Female Maghrebi Muslim" ~ 0,
                                                   idprof.exp.2nd == "Male Maghrebi Muslim" ~ 0,
                                                   idprof.exp.2nd == "Female Maghrebi Christian" ~ 0,
                                                   idprof.exp.2nd == "Male Maghrebi Christian" ~ 0,
                                                   idprof.exp.2nd == "Female Maghrebi Non Religious" ~ 0,
                                                   idprof.exp.2nd == "Male Maghrebi Non Religious" ~ 0,
                                                   
                                                   idprof.exp.2nd == "Female SSA Muslim" ~ 0,
                                                   idprof.exp.2nd == "Male SSA Muslim" ~ 0,
                                                   idprof.exp.2nd == "Female SSA Christian" ~ 0,
                                                   idprof.exp.2nd == "Male SSA Christian" ~ 0,
                                                   idprof.exp.2nd == "Female SSA Non Religious" ~ 0,
                                                   idprof.exp.2nd == "Male SSA Non Religious" ~ 0,
                                                   
                                                   idprof.exp.2nd == "Female French Muslim" ~ 1,
                                                   idprof.exp.2nd == "Male French Muslim" ~ 1,
                                                   idprof.exp.2nd == "Female French Christian" ~ 1,
                                                   idprof.exp.2nd == "Male French Christian" ~ 1,
                                                   idprof.exp.2nd == "Female French Non Religious" ~ 1,
                                                   idprof.exp.2nd == "Male French Non Religious" ~ 1))

#DE
#1st
DE <- DE %>% mutate(prof.exp.Tur.1st = case_when(idprof.exp.1st == "Female Turkish Muslim" ~ 1,
                                                 idprof.exp.1st == "Male Turkish Muslim" ~ 1,
                                                 idprof.exp.1st == "Female Turkish Christian" ~ 1,
                                                 idprof.exp.1st == "Male Turkish Christian" ~ 1,
                                                 idprof.exp.1st == "Female Turkish Non Religious" ~ 1,
                                                 idprof.exp.1st == "Male Turkish Non Religious" ~ 1,
                                                 
                                                 idprof.exp.1st == "Female FSU Muslim" ~ 0,
                                                 idprof.exp.1st == "Male FSU Muslim" ~ 0,
                                                 idprof.exp.1st == "Female FSU Christian" ~ 0,
                                                 idprof.exp.1st == "Male FSU Christian" ~ 0,
                                                 idprof.exp.1st == "Female FSU Non Religious" ~ 0,
                                                 idprof.exp.1st == "Male FSU Non Religious" ~ 0,
                                                 
                                                 idprof.exp.1st == "Female Other Muslim" ~ 0,
                                                 idprof.exp.1st == "Male Other Muslim" ~ 0,
                                                 idprof.exp.1st == "Female Other Christian" ~ 0,
                                                 idprof.exp.1st == "Male Other Christian" ~ 0,
                                                 idprof.exp.1st == "Female Other Non Religious" ~ 0,
                                                 idprof.exp.1st == "Male Other Non Religious" ~ 0,
                                                 
                                                 idprof.exp.1st == "Female German Muslim" ~ 0,
                                                 idprof.exp.1st == "Male German Muslim" ~ 0,
                                                 idprof.exp.1st == "Female German Christian" ~ 0,
                                                 idprof.exp.1st == "Male German Christian" ~ 0,
                                                 idprof.exp.1st == "Female German Non Religious" ~ 0,
                                                 idprof.exp.1st == "Male German Non Religious" ~ 0))

DE <- DE %>% mutate(prof.exp.FSU.1st = case_when(idprof.exp.1st == "Female Turkish Muslim" ~ 0,
                                                 idprof.exp.1st == "Male Turkish Muslim" ~ 0,
                                                 idprof.exp.1st == "Female Turkish Christian" ~ 0,
                                                 idprof.exp.1st == "Male Turkish Christian" ~ 0,
                                                 idprof.exp.1st == "Female Turkish Non Religious" ~ 0,
                                                 idprof.exp.1st == "Male Turkish Non Religious" ~ 0,
                                                 
                                                 idprof.exp.1st == "Female FSU Muslim" ~ 1,
                                                 idprof.exp.1st == "Male FSU Muslim" ~ 1,
                                                 idprof.exp.1st == "Female FSU Christian" ~ 1,
                                                 idprof.exp.1st == "Male FSU Christian" ~ 1,
                                                 idprof.exp.1st == "Female FSU Non Religious" ~ 1,
                                                 idprof.exp.1st == "Male FSU Non Religious" ~ 1,
                                                 
                                                 idprof.exp.1st == "Female Other Muslim" ~ 0,
                                                 idprof.exp.1st == "Male Other Muslim" ~ 0,
                                                 idprof.exp.1st == "Female Other Christian" ~ 0,
                                                 idprof.exp.1st == "Male Other Christian" ~ 0,
                                                 idprof.exp.1st == "Female Other Non Religious" ~ 0,
                                                 idprof.exp.1st == "Male Other Non Religious" ~ 0,
                                                 
                                                 idprof.exp.1st == "Female German Muslim" ~ 0,
                                                 idprof.exp.1st == "Male German Muslim" ~ 0,
                                                 idprof.exp.1st == "Female German Christian" ~ 0,
                                                 idprof.exp.1st == "Male German Christian" ~ 0,
                                                 idprof.exp.1st == "Female German Non Religious" ~ 0,
                                                 idprof.exp.1st == "Male German Non Religious" ~ 0))

DE <- DE %>% mutate(prof.exp.Oth.1st = case_when(idprof.exp.1st == "Female Turkish Muslim" ~ 0,
                                                 idprof.exp.1st == "Male Turkish Muslim" ~ 0,
                                                 idprof.exp.1st == "Female Turkish Christian" ~ 0,
                                                 idprof.exp.1st == "Male Turkish Christian" ~ 0,
                                                 idprof.exp.1st == "Female Turkish Non Religious" ~ 0,
                                                 idprof.exp.1st == "Male Turkish Non Religious" ~ 0,
                                                 
                                                 idprof.exp.1st == "Female FSU Muslim" ~ 0,
                                                 idprof.exp.1st == "Male FSU Muslim" ~ 0,
                                                 idprof.exp.1st == "Female FSU Christian" ~ 0,
                                                 idprof.exp.1st == "Male FSU Christian" ~ 0,
                                                 idprof.exp.1st == "Female FSU Non Religious" ~ 0,
                                                 idprof.exp.1st == "Male FSU Non Religious" ~ 0,
                                                 
                                                 idprof.exp.1st == "Female Other Muslim" ~ 1,
                                                 idprof.exp.1st == "Male Other Muslim" ~ 1,
                                                 idprof.exp.1st == "Female Other Christian" ~ 1,
                                                 idprof.exp.1st == "Male Other Christian" ~ 1,
                                                 idprof.exp.1st == "Female Other Non Religious" ~ 1,
                                                 idprof.exp.1st == "Male Other Non Religious" ~ 1,
                                                 
                                                 idprof.exp.1st == "Female German Muslim" ~ 0,
                                                 idprof.exp.1st == "Male German Muslim" ~ 0,
                                                 idprof.exp.1st == "Female German Christian" ~ 0,
                                                 idprof.exp.1st == "Male German Christian" ~ 0,
                                                 idprof.exp.1st == "Female German Non Religious" ~ 0,
                                                 idprof.exp.1st == "Male German Non Religious" ~ 0))

DE <- DE %>% mutate(prof.exp.NoMig.1st = case_when(idprof.exp.1st == "Female Turkish Muslim" ~ 0,
                                                   idprof.exp.1st == "Male Turkish Muslim" ~ 0,
                                                   idprof.exp.1st == "Female Turkish Christian" ~ 0,
                                                   idprof.exp.1st == "Male Turkish Christian" ~ 0,
                                                   idprof.exp.1st == "Female Turkish Non Religious" ~ 0,
                                                   idprof.exp.1st == "Male Turkish Non Religious" ~ 0,
                                                   
                                                   idprof.exp.1st == "Female FSU Muslim" ~ 0,
                                                   idprof.exp.1st == "Male FSU Muslim" ~ 0,
                                                   idprof.exp.1st == "Female FSU Christian" ~ 0,
                                                   idprof.exp.1st == "Male FSU Christian" ~ 0,
                                                   idprof.exp.1st == "Female FSU Non Religious" ~ 0,
                                                   idprof.exp.1st == "Male FSU Non Religious" ~ 0,
                                                   
                                                   idprof.exp.1st == "Female Other Muslim" ~ 0,
                                                   idprof.exp.1st == "Male Other Muslim" ~ 0,
                                                   idprof.exp.1st == "Female Other Christian" ~ 0,
                                                   idprof.exp.1st == "Male Other Christian" ~ 0,
                                                   idprof.exp.1st == "Female Other Non Religious" ~ 0,
                                                   idprof.exp.1st == "Male Other Non Religious" ~ 0,
                                                   
                                                   idprof.exp.1st == "Female German Muslim" ~ 1,
                                                   idprof.exp.1st == "Male German Muslim" ~ 1,
                                                   idprof.exp.1st == "Female German Christian" ~ 1,
                                                   idprof.exp.1st == "Male German Christian" ~ 1,
                                                   idprof.exp.1st == "Female German Non Religious" ~ 1,
                                                   idprof.exp.1st == "Male German Non Religious" ~ 1))

#2nd
DE <- DE %>% mutate(prof.exp.Tur.2nd = case_when(idprof.exp.2nd == "Female Turkish Muslim" ~ 1,
                                                 idprof.exp.2nd == "Male Turkish Muslim" ~ 1,
                                                 idprof.exp.2nd == "Female Turkish Christian" ~ 1,
                                                 idprof.exp.2nd == "Male Turkish Christian" ~ 1,
                                                 idprof.exp.2nd == "Female Turkish Non Religious" ~ 1,
                                                 idprof.exp.2nd == "Male Turkish Non Religious" ~ 1,
                                                 
                                                 idprof.exp.2nd == "Female FSU Muslim" ~ 0,
                                                 idprof.exp.2nd == "Male FSU Muslim" ~ 0,
                                                 idprof.exp.2nd == "Female FSU Christian" ~ 0,
                                                 idprof.exp.2nd == "Male FSU Christian" ~ 0,
                                                 idprof.exp.2nd == "Female FSU Non Religious" ~ 0,
                                                 idprof.exp.2nd == "Male FSU Non Religious" ~ 0,
                                                 
                                                 idprof.exp.2nd == "Female Other Muslim" ~ 0,
                                                 idprof.exp.2nd == "Male Other Muslim" ~ 0,
                                                 idprof.exp.2nd == "Female Other Christian" ~ 0,
                                                 idprof.exp.2nd == "Male Other Christian" ~ 0,
                                                 idprof.exp.2nd == "Female Other Non Religious" ~ 0,
                                                 idprof.exp.2nd == "Male Other Non Religious" ~ 0,
                                                 
                                                 idprof.exp.2nd == "Female German Muslim" ~ 0,
                                                 idprof.exp.2nd == "Male German Muslim" ~ 0,
                                                 idprof.exp.2nd == "Female German Christian" ~ 0,
                                                 idprof.exp.2nd == "Male German Christian" ~ 0,
                                                 idprof.exp.2nd == "Female German Non Religious" ~ 0,
                                                 idprof.exp.2nd == "Male German Non Religious" ~ 0))

DE <- DE %>% mutate(prof.exp.FSU.2nd = case_when(idprof.exp.2nd == "Female Turkish Muslim" ~ 0,
                                                 idprof.exp.2nd == "Male Turkish Muslim" ~ 0,
                                                 idprof.exp.2nd == "Female Turkish Christian" ~ 0,
                                                 idprof.exp.2nd == "Male Turkish Christian" ~ 0,
                                                 idprof.exp.2nd == "Female Turkish Non Religious" ~ 0,
                                                 idprof.exp.2nd == "Male Turkish Non Religious" ~ 0,
                                                 
                                                 idprof.exp.2nd == "Female FSU Muslim" ~ 1,
                                                 idprof.exp.2nd == "Male FSU Muslim" ~ 1,
                                                 idprof.exp.2nd == "Female FSU Christian" ~ 1,
                                                 idprof.exp.2nd == "Male FSU Christian" ~ 1,
                                                 idprof.exp.2nd == "Female FSU Non Religious" ~ 1,
                                                 idprof.exp.2nd == "Male FSU Non Religious" ~ 1,
                                                 
                                                 idprof.exp.2nd == "Female Other Muslim" ~ 0,
                                                 idprof.exp.2nd == "Male Other Muslim" ~ 0,
                                                 idprof.exp.2nd == "Female Other Christian" ~ 0,
                                                 idprof.exp.2nd == "Male Other Christian" ~ 0,
                                                 idprof.exp.2nd == "Female Other Non Religious" ~ 0,
                                                 idprof.exp.2nd == "Male Other Non Religious" ~ 0,
                                                 
                                                 idprof.exp.2nd == "Female German Muslim" ~ 0,
                                                 idprof.exp.2nd == "Male German Muslim" ~ 0,
                                                 idprof.exp.2nd == "Female German Christian" ~ 0,
                                                 idprof.exp.2nd == "Male German Christian" ~ 0,
                                                 idprof.exp.2nd == "Female German Non Religious" ~ 0,
                                                 idprof.exp.2nd == "Male German Non Religious" ~ 0))

DE <- DE %>% mutate(prof.exp.Oth.2nd = case_when(idprof.exp.2nd == "Female Turkish Muslim" ~ 0,
                                                 idprof.exp.2nd == "Male Turkish Muslim" ~ 0,
                                                 idprof.exp.2nd == "Female Turkish Christian" ~ 0,
                                                 idprof.exp.2nd == "Male Turkish Christian" ~ 0,
                                                 idprof.exp.2nd == "Female Turkish Non Religious" ~ 0,
                                                 idprof.exp.2nd == "Male Turkish Non Religious" ~ 0,
                                                 
                                                 idprof.exp.2nd == "Female FSU Muslim" ~ 0,
                                                 idprof.exp.2nd == "Male FSU Muslim" ~ 0,
                                                 idprof.exp.2nd == "Female FSU Christian" ~ 0,
                                                 idprof.exp.2nd == "Male FSU Christian" ~ 0,
                                                 idprof.exp.2nd == "Female FSU Non Religious" ~ 0,
                                                 idprof.exp.2nd == "Male FSU Non Religious" ~ 0,
                                                 
                                                 idprof.exp.2nd == "Female Other Muslim" ~ 1,
                                                 idprof.exp.2nd == "Male Other Muslim" ~ 1,
                                                 idprof.exp.2nd == "Female Other Christian" ~ 1,
                                                 idprof.exp.2nd == "Male Other Christian" ~ 1,
                                                 idprof.exp.2nd == "Female Other Non Religious" ~ 1,
                                                 idprof.exp.2nd == "Male Other Non Religious" ~ 1,
                                                 
                                                 idprof.exp.2nd == "Female German Muslim" ~ 0,
                                                 idprof.exp.2nd == "Male German Muslim" ~ 0,
                                                 idprof.exp.2nd == "Female German Christian" ~ 0,
                                                 idprof.exp.2nd == "Male German Christian" ~ 0,
                                                 idprof.exp.2nd == "Female German Non Religious" ~ 0,
                                                 idprof.exp.2nd == "Male German Non Religious" ~ 0))

DE <- DE %>% mutate(prof.exp.NoMig.2nd = case_when(idprof.exp.2nd == "Female Turkish Muslim" ~ 0,
                                                   idprof.exp.2nd == "Male Turkish Muslim" ~ 0,
                                                   idprof.exp.2nd == "Female Turkish Christian" ~ 0,
                                                   idprof.exp.2nd == "Male Turkish Christian" ~ 0,
                                                   idprof.exp.2nd == "Female Turkish Non Religious" ~ 0,
                                                   idprof.exp.2nd == "Male Turkish Non Religious" ~ 0,
                                                   
                                                   idprof.exp.2nd == "Female FSU Muslim" ~ 0,
                                                   idprof.exp.2nd == "Male FSU Muslim" ~ 0,
                                                   idprof.exp.2nd == "Female FSU Christian" ~ 0,
                                                   idprof.exp.2nd == "Male FSU Christian" ~ 0,
                                                   idprof.exp.2nd == "Female FSU Non Religious" ~ 0,
                                                   idprof.exp.2nd == "Male FSU Non Religious" ~ 0,
                                                   
                                                   idprof.exp.2nd == "Female Other Muslim" ~ 0,
                                                   idprof.exp.2nd == "Male Other Muslim" ~ 0,
                                                   idprof.exp.2nd == "Female Other Christian" ~ 0,
                                                   idprof.exp.2nd == "Male Other Christian" ~ 0,
                                                   idprof.exp.2nd == "Female Other Non Religious" ~ 0,
                                                   idprof.exp.2nd == "Male Other Non Religious" ~ 0,
                                                   
                                                   idprof.exp.2nd == "Female German Muslim" ~ 1,
                                                   idprof.exp.2nd == "Male German Muslim" ~ 1,
                                                   idprof.exp.2nd == "Female German Christian" ~ 1,
                                                   idprof.exp.2nd == "Male German Christian" ~ 1,
                                                   idprof.exp.2nd == "Female German Non Religious" ~ 1,
                                                   idprof.exp.2nd == "Male German Non Religious" ~ 1))

#NL
#1st
NL <- NL %>% mutate(prof.exp.Tur.1st = case_when(idprof.exp.1st == "Female Turkish Muslim" ~ 1,
                                                 idprof.exp.1st == "Male Turkish Muslim" ~ 1,
                                                 idprof.exp.1st == "Female Turkish Christian" ~ 1,
                                                 idprof.exp.1st == "Male Turkish Christian" ~ 1,
                                                 idprof.exp.1st == "Female Turkish Non Religious" ~ 1,
                                                 idprof.exp.1st == "Male Turkish Non Religious" ~ 1,
                                                 
                                                 idprof.exp.1st == "Female Moroccan Muslim" ~ 0,
                                                 idprof.exp.1st == "Male Moroccan Muslim" ~ 0,
                                                 idprof.exp.1st == "Female Moroccan Christian" ~ 0,
                                                 idprof.exp.1st == "Male Moroccan Christian" ~ 0,
                                                 idprof.exp.1st == "Female Moroccan Non Religious" ~ 0,
                                                 idprof.exp.1st == "Male Moroccan Non Religious" ~ 0,
                                                 
                                                 idprof.exp.1st == "Female Surinamese Muslim" ~ 0,
                                                 idprof.exp.1st == "Male Surinamese Muslim" ~ 0,
                                                 idprof.exp.1st == "Female Surinamese Christian" ~ 0,
                                                 idprof.exp.1st == "Male Surinamese Christian" ~ 0,
                                                 idprof.exp.1st == "Female Surinamese Non Religious" ~ 0,
                                                 idprof.exp.1st == "Male Surinamese Non Religious" ~ 0,
                                                 
                                                 idprof.exp.1st == "Female Dutch Muslim" ~ 0,
                                                 idprof.exp.1st == "Male Dutch Muslim" ~ 0,
                                                 idprof.exp.1st == "Female Dutch Christian" ~ 0,
                                                 idprof.exp.1st == "Male Dutch Christian" ~ 0,
                                                 idprof.exp.1st == "Female Dutch Non Religious" ~ 0,
                                                 idprof.exp.1st == "Male Dutch Non Religious" ~ 0))

NL <- NL %>% mutate(prof.exp.Mor.1st = case_when(idprof.exp.1st == "Female Turkish Muslim" ~ 0,
                                                 idprof.exp.1st == "Male Turkish Muslim" ~ 0,
                                                 idprof.exp.1st == "Female Turkish Christian" ~ 0,
                                                 idprof.exp.1st == "Male Turkish Christian" ~ 0,
                                                 idprof.exp.1st == "Female Turkish Non Religious" ~ 0,
                                                 idprof.exp.1st == "Male Turkish Non Religious" ~ 0,
                                                 
                                                 idprof.exp.1st == "Female Moroccan Muslim" ~ 1,
                                                 idprof.exp.1st == "Male Moroccan Muslim" ~ 1,
                                                 idprof.exp.1st == "Female Moroccan Christian" ~ 1,
                                                 idprof.exp.1st == "Male Moroccan Christian" ~ 1,
                                                 idprof.exp.1st == "Female Moroccan Non Religious" ~ 1,
                                                 idprof.exp.1st == "Male Moroccan Non Religious" ~ 1,
                                                 
                                                 idprof.exp.1st == "Female Surinamese Muslim" ~ 0,
                                                 idprof.exp.1st == "Male Surinamese Muslim" ~ 0,
                                                 idprof.exp.1st == "Female Surinamese Christian" ~ 0,
                                                 idprof.exp.1st == "Male Surinamese Christian" ~ 0,
                                                 idprof.exp.1st == "Female Surinamese Non Religious" ~ 0,
                                                 idprof.exp.1st == "Male Surinamese Non Religious" ~ 0,
                                                 
                                                 idprof.exp.1st == "Female Dutch Muslim" ~ 0,
                                                 idprof.exp.1st == "Male Dutch Muslim" ~ 0,
                                                 idprof.exp.1st == "Female Dutch Christian" ~ 0,
                                                 idprof.exp.1st == "Male Dutch Christian" ~ 0,
                                                 idprof.exp.1st == "Female Dutch Non Religious" ~ 0,
                                                 idprof.exp.1st == "Male Dutch Non Religious" ~ 0))

NL <- NL %>% mutate(prof.exp.Sur.1st = case_when(idprof.exp.1st == "Female Turkish Muslim" ~ 0,
                                                 idprof.exp.1st == "Male Turkish Muslim" ~ 0,
                                                 idprof.exp.1st == "Female Turkish Christian" ~ 0,
                                                 idprof.exp.1st == "Male Turkish Christian" ~ 0,
                                                 idprof.exp.1st == "Female Turkish Non Religious" ~ 0,
                                                 idprof.exp.1st == "Male Turkish Non Religious" ~ 0,
                                                 
                                                 idprof.exp.1st == "Female Moroccan Muslim" ~ 0,
                                                 idprof.exp.1st == "Male Moroccan Muslim" ~ 0,
                                                 idprof.exp.1st == "Female Moroccan Christian" ~ 0,
                                                 idprof.exp.1st == "Male Moroccan Christian" ~ 0,
                                                 idprof.exp.1st == "Female Moroccan Non Religious" ~ 0,
                                                 idprof.exp.1st == "Male Moroccan Non Religious" ~ 0,
                                                 
                                                 idprof.exp.1st == "Female Surinamese Muslim" ~ 1,
                                                 idprof.exp.1st == "Male Surinamese Muslim" ~ 1,
                                                 idprof.exp.1st == "Female Surinamese Christian" ~ 1,
                                                 idprof.exp.1st == "Male Surinamese Christian" ~ 1,
                                                 idprof.exp.1st == "Female Surinamese Non Religious" ~ 1,
                                                 idprof.exp.1st == "Male Surinamese Non Religious" ~ 1,
                                                 
                                                 idprof.exp.1st == "Female Dutch Muslim" ~ 0,
                                                 idprof.exp.1st == "Male Dutch Muslim" ~ 0,
                                                 idprof.exp.1st == "Female Dutch Christian" ~ 0,
                                                 idprof.exp.1st == "Male Dutch Christian" ~ 0,
                                                 idprof.exp.1st == "Female Dutch Non Religious" ~ 0,
                                                 idprof.exp.1st == "Male Dutch Non Religious" ~ 0))

NL <- NL %>% mutate(prof.exp.NoMig.1st = case_when(idprof.exp.1st == "Female Turkish Muslim" ~ 0,
                                                   idprof.exp.1st == "Male Turkish Muslim" ~ 0,
                                                   idprof.exp.1st == "Female Turkish Christian" ~ 0,
                                                   idprof.exp.1st == "Male Turkish Christian" ~ 0,
                                                   idprof.exp.1st == "Female Turkish Non Religious" ~ 0,
                                                   idprof.exp.1st == "Male Turkish Non Religious" ~ 0,
                                                   
                                                   idprof.exp.1st == "Female Moroccan Muslim" ~ 0,
                                                   idprof.exp.1st == "Male Moroccan Muslim" ~ 0,
                                                   idprof.exp.1st == "Female Moroccan Christian" ~ 0,
                                                   idprof.exp.1st == "Male Moroccan Christian" ~ 0,
                                                   idprof.exp.1st == "Female Moroccan Non Religious" ~ 0,
                                                   idprof.exp.1st == "Male Moroccan Non Religious" ~ 0,
                                                   
                                                   idprof.exp.1st == "Female Surinamese Muslim" ~ 0,
                                                   idprof.exp.1st == "Male Surinamese Muslim" ~ 0,
                                                   idprof.exp.1st == "Female Surinamese Christian" ~ 0,
                                                   idprof.exp.1st == "Male Surinamese Christian" ~ 0,
                                                   idprof.exp.1st == "Female Surinamese Non Religious" ~ 0,
                                                   idprof.exp.1st == "Male Surinamese Non Religious" ~ 0,
                                                   
                                                   idprof.exp.1st == "Female Dutch Muslim" ~ 1,
                                                   idprof.exp.1st == "Male Dutch Muslim" ~ 1,
                                                   idprof.exp.1st == "Female Dutch Christian" ~ 1,
                                                   idprof.exp.1st == "Male Dutch Christian" ~ 1,
                                                   idprof.exp.1st == "Female Dutch Non Religious" ~ 1,
                                                   idprof.exp.1st == "Male Dutch Non Religious" ~ 1))
#2nd
NL <- NL %>% mutate(prof.exp.Tur.2nd = case_when(idprof.exp.2nd == "Female Turkish Muslim" ~ 1,
                                                 idprof.exp.2nd == "Male Turkish Muslim" ~ 1,
                                                 idprof.exp.2nd == "Female Turkish Christian" ~ 1,
                                                 idprof.exp.2nd == "Male Turkish Christian" ~ 1,
                                                 idprof.exp.2nd == "Female Turkish Non Religious" ~ 1,
                                                 idprof.exp.2nd == "Male Turkish Non Religious" ~ 1,
                                                 
                                                 idprof.exp.2nd == "Female Moroccan Muslim" ~ 0,
                                                 idprof.exp.2nd == "Male Moroccan Muslim" ~ 0,
                                                 idprof.exp.2nd == "Female Moroccan Christian" ~ 0,
                                                 idprof.exp.2nd == "Male Moroccan Christian" ~ 0,
                                                 idprof.exp.2nd == "Female Moroccan Non Religious" ~ 0,
                                                 idprof.exp.2nd == "Male Moroccan Non Religious" ~ 0,
                                                 
                                                 idprof.exp.2nd == "Female Surinamese Muslim" ~ 0,
                                                 idprof.exp.2nd == "Male Surinamese Muslim" ~ 0,
                                                 idprof.exp.2nd == "Female Surinamese Christian" ~ 0,
                                                 idprof.exp.2nd == "Male Surinamese Christian" ~ 0,
                                                 idprof.exp.2nd == "Female Surinamese Non Religious" ~ 0,
                                                 idprof.exp.2nd == "Male Surinamese Non Religious" ~ 0,
                                                 
                                                 idprof.exp.2nd == "Female Dutch Muslim" ~ 0,
                                                 idprof.exp.2nd == "Male Dutch Muslim" ~ 0,
                                                 idprof.exp.2nd == "Female Dutch Christian" ~ 0,
                                                 idprof.exp.2nd == "Male Dutch Christian" ~ 0,
                                                 idprof.exp.2nd == "Female Dutch Non Religious" ~ 0,
                                                 idprof.exp.2nd == "Male Dutch Non Religious" ~ 0))

NL <- NL %>% mutate(prof.exp.Mor.2nd = case_when(idprof.exp.2nd == "Female Turkish Muslim" ~ 0,
                                                 idprof.exp.2nd == "Male Turkish Muslim" ~ 0,
                                                 idprof.exp.2nd == "Female Turkish Christian" ~ 0,
                                                 idprof.exp.2nd == "Male Turkish Christian" ~ 0,
                                                 idprof.exp.2nd == "Female Turkish Non Religious" ~ 0,
                                                 idprof.exp.2nd == "Male Turkish Non Religious" ~ 0,
                                                 
                                                 idprof.exp.2nd == "Female Moroccan Muslim" ~ 1,
                                                 idprof.exp.2nd == "Male Moroccan Muslim" ~ 1,
                                                 idprof.exp.2nd == "Female Moroccan Christian" ~ 1,
                                                 idprof.exp.2nd == "Male Moroccan Christian" ~ 1,
                                                 idprof.exp.2nd == "Female Moroccan Non Religious" ~ 1,
                                                 idprof.exp.2nd == "Male Moroccan Non Religious" ~ 1,
                                                 
                                                 idprof.exp.2nd == "Female Surinamese Muslim" ~ 0,
                                                 idprof.exp.2nd == "Male Surinamese Muslim" ~ 0,
                                                 idprof.exp.2nd == "Female Surinamese Christian" ~ 0,
                                                 idprof.exp.2nd == "Male Surinamese Christian" ~ 0,
                                                 idprof.exp.2nd == "Female Surinamese Non Religious" ~ 0,
                                                 idprof.exp.2nd == "Male Surinamese Non Religious" ~ 0,
                                                 
                                                 idprof.exp.2nd == "Female Dutch Muslim" ~ 0,
                                                 idprof.exp.2nd == "Male Dutch Muslim" ~ 0,
                                                 idprof.exp.2nd == "Female Dutch Christian" ~ 0,
                                                 idprof.exp.2nd == "Male Dutch Christian" ~ 0,
                                                 idprof.exp.2nd == "Female Dutch Non Religious" ~ 0,
                                                 idprof.exp.2nd == "Male Dutch Non Religious" ~ 0))

NL <- NL %>% mutate(prof.exp.Sur.2nd = case_when(idprof.exp.2nd == "Female Turkish Muslim" ~ 0,
                                                 idprof.exp.2nd == "Male Turkish Muslim" ~ 0,
                                                 idprof.exp.2nd == "Female Turkish Christian" ~ 0,
                                                 idprof.exp.2nd == "Male Turkish Christian" ~ 0,
                                                 idprof.exp.2nd == "Female Turkish Non Religious" ~ 0,
                                                 idprof.exp.2nd == "Male Turkish Non Religious" ~ 0,
                                                 
                                                 idprof.exp.2nd == "Female Moroccan Muslim" ~ 0,
                                                 idprof.exp.2nd == "Male Moroccan Muslim" ~ 0,
                                                 idprof.exp.2nd == "Female Moroccan Christian" ~ 0,
                                                 idprof.exp.2nd == "Male Moroccan Christian" ~ 0,
                                                 idprof.exp.2nd == "Female Moroccan Non Religious" ~ 0,
                                                 idprof.exp.2nd == "Male Moroccan Non Religious" ~ 0,
                                                 
                                                 idprof.exp.2nd == "Female Surinamese Muslim" ~ 1,
                                                 idprof.exp.2nd == "Male Surinamese Muslim" ~ 1,
                                                 idprof.exp.2nd == "Female Surinamese Christian" ~ 1,
                                                 idprof.exp.2nd == "Male Surinamese Christian" ~ 1,
                                                 idprof.exp.2nd == "Female Surinamese Non Religious" ~ 1,
                                                 idprof.exp.2nd == "Male Surinamese Non Religious" ~ 1,
                                                 
                                                 idprof.exp.2nd == "Female Dutch Muslim" ~ 0,
                                                 idprof.exp.2nd == "Male Dutch Muslim" ~ 0,
                                                 idprof.exp.2nd == "Female Dutch Christian" ~ 0,
                                                 idprof.exp.2nd == "Male Dutch Christian" ~ 0,
                                                 idprof.exp.2nd == "Female Dutch Non Religious" ~ 0,
                                                 idprof.exp.2nd == "Male Dutch Non Religious" ~ 0))

NL <- NL %>% mutate(prof.exp.NoMig.2nd = case_when(idprof.exp.2nd == "Female Turkish Muslim" ~ 0,
                                                   idprof.exp.2nd == "Male Turkish Muslim" ~ 0,
                                                   idprof.exp.2nd == "Female Turkish Christian" ~ 0,
                                                   idprof.exp.2nd == "Male Turkish Christian" ~ 0,
                                                   idprof.exp.2nd == "Female Turkish Non Religious" ~ 0,
                                                   idprof.exp.2nd == "Male Turkish Non Religious" ~ 0,
                                                   
                                                   idprof.exp.2nd == "Female Moroccan Muslim" ~ 0,
                                                   idprof.exp.2nd == "Male Moroccan Muslim" ~ 0,
                                                   idprof.exp.2nd == "Female Moroccan Christian" ~ 0,
                                                   idprof.exp.2nd == "Male Moroccan Christian" ~ 0,
                                                   idprof.exp.2nd == "Female Moroccan Non Religious" ~ 0,
                                                   idprof.exp.2nd == "Male Moroccan Non Religious" ~ 0,
                                                   
                                                   idprof.exp.2nd == "Female Surinamese Muslim" ~ 0,
                                                   idprof.exp.2nd == "Male Surinamese Muslim" ~ 0,
                                                   idprof.exp.2nd == "Female Surinamese Christian" ~ 0,
                                                   idprof.exp.2nd == "Male Surinamese Christian" ~ 0,
                                                   idprof.exp.2nd == "Female Surinamese Non Religious" ~ 0,
                                                   idprof.exp.2nd == "Male Surinamese Non Religious" ~ 0,
                                                   
                                                   idprof.exp.2nd == "Female Dutch Muslim" ~ 1,
                                                   idprof.exp.2nd == "Male Dutch Muslim" ~ 1,
                                                   idprof.exp.2nd == "Female Dutch Christian" ~ 1,
                                                   idprof.exp.2nd == "Male Dutch Christian" ~ 1,
                                                   idprof.exp.2nd == "Female Dutch Non Religious" ~ 1,
                                                   idprof.exp.2nd == "Male Dutch Non Religious" ~ 1))

#---------------#
#--- Weights ---#
#---------------#

FR <- FR %>% mutate(w8eth = case_when(FR$catrace == "France" ~ 2.072058,
                                      FR$catrace == "North-Africa" ~ 0.1111513,
                                      FR$catrace == "Sub-Saharan Africa" ~ 0.07401234,
                                      FR$catrace == "Turkey" ~ 0.05011495,
                                      FR$catrace == "Other" ~ 0.449313))
FR <- FR %>% mutate(EDU2 = case_when(FR$EDU == 1 ~ "below upper secondary",
                                     FR$EDU == 2 ~ "below upper secondary",
                                     FR$EDU == 3 ~ "below upper secondary",
                                     FR$EDU == 4 ~ "below upper secondary",
                                     FR$EDU == 5 ~ "upper secondary",
                                     FR$EDU == 6 ~ "upper secondary",
                                     FR$EDU == 7 ~ "upper secondary",
                                     FR$EDU == 8 ~ "tertiary",
                                     FR$EDU == 9 ~ "tertiary",
                                     FR$EDU == 10 ~ "tertiary",
                                     FR$EDU == 11 ~ "tertiary"))
FR <- FR %>% mutate(w8edu = case_when(FR$EDU2 == "below upper secondary" ~ 0.9080662,
                                      FR$EDU2 == "upper secondary" ~ 1.512092,
                                      FR$EDU2 == "tertiary" ~ 1.095126))
FR <- FR %>% mutate(w8gen = case_when(FR$Female == 1 ~ 0.8849019,
                                      FR$Female == 0 ~ 1.216083))
FR <- FR %>% mutate(w8reg = case_when(V660 == 1 ~ 1.053099,
                                      V660 == 2 ~ 0.9839522,
                                      V660 == 3 ~ 1.710078,
                                      V660 == 4 ~ 1.038853,
                                      V660 == 5 ~ 0.7766013,
                                      V660 == 6 ~ 0.9191073,
                                      V660 == 7 ~ 1.325781,
                                      V660 == 8 ~ 0.6741297,
                                      V660 == 9 ~ 1.506768,
                                      V660 == 10 ~1.578526,
                                      V660 == 11 ~0.9594831,
                                      V660 == 12 ~1.222811,
                                      V660 == 13 ~0.8972948))
FR <- FR %>% mutate(w8urb = case_when(V670 == 1 ~ ((35.35/130.86)*100)/((377/1199)*100),
                                      V670 == 2 ~ ((33.81/130.86)*100)/((268/1199)*100),
                                      V670 == 3 ~ ((30.85/130.86)*100)/((340/1199)*100),
                                      V670 == 4 ~ ((22.34/130.86)*100)/((186/1199)*100),
                                      V670 == 5 ~ ((8.510/130.86)*100)/((28/1199)*100)))
FR$w8 <- FR$w8eth*FR$w8gen*FR$w8edu*FR$w8reg*FR$w8urb
FR  <- mutate(FR, w8 = ifelse(is.na(w8), 1, w8))

#DE
DE <- DE %>% mutate(w8eth = case_when(DE$catraceDEb == "German" ~ (59466174/69488809)/(346/954),
                                      DE$catraceDEb == "FSU" ~ (598230/69488809)/(266/954),
                                      DE$catraceDEb == "Turkey" ~ (1472430/69488809)/(198/954),
                                      DE$catraceDEb == "Other" ~ (7951975/69488809)/(144/954)))
DE  <- mutate(DE, EDU = ifelse(is.na(EDU), 5, EDU)) #missing go to middle value
DE <- DE %>% mutate(EDU2 = case_when(EDU == 1 ~ "below upper secondary",
                                     EDU == 2 ~ "below upper secondary",
                                     EDU == 3 ~ "below upper secondary",
                                     EDU == 4 ~ "upper secondary",
                                     EDU == 5 ~ "upper secondary",
                                     EDU == 6 ~ "upper secondary",
                                     EDU == 7 ~ "tertiary",
                                     EDU == 8 ~ "tertiary",
                                     EDU == 9 ~ "tertiary"))
DE <- DE %>% mutate(w8edu = case_when(V670 == 1 ~ ((43.54/115.65)*100)/((343/954)*100),
                                      V670 == 2 ~ ((40.81/115.65)*100)/((144/954)*100),
                                      V670 == 3 ~ ((15.65/115.65)*100)/((321/954)*100),
                                      V670 == 4 ~ ((13.48/115.65)*100)/((141/954)*100),
                                      V670 == 5 ~ ((2.170/115.65)*100)/((5/954)*100)))
DE <- DE %>% mutate(w8edu = case_when(DE$EDU2 == "below upper secondary" ~ 0.5715405,
                                      DE$EDU2 == "upper secondary" ~ 1.161742,
                                      DE$EDU2 == "tertiary" ~ 1.071869))
DE  <- mutate(DE, EDU = ifelse(is.na(EDU), 5.148982, EDU))
DE <- DE %>% mutate(w8gen = case_when(DE$Female == 1 ~ 0.9065568,
                                      DE$Female == 0 ~ 1.121364))
DE <- DE %>% mutate(w8reg = case_when(V660 == 1 ~ 0.8904328,
                                      V660 == 2 ~ 1.131978,
                                      V660 == 3 ~ 0.7015416,
                                      V660 == 4 ~ 1.701675,
                                      V660 == 5 ~ 0.6511685,
                                      V660 == 6 ~ 0.4708828,
                                      V660 == 7 ~ 0.8904959,
                                      V660 == 8 ~ 1.024825,
                                      V660 == 9 ~ 1.053956,
                                      V660 == 10 ~ 0.8990018,
                                      V660 == 11 ~ 1.304469,
                                      V660 == 12 ~ 1.617217,
                                      V660 == 13 ~ 1.610666,
                                      V660 == 14 ~ 1.798301,
                                      V660 == 15 ~ 1.189607,
                                      V660 == 16 ~ 1.631456))
DE <- DE %>% mutate(w8urb = case_when(V670 == 1 ~ ((43.54/115.65)*100)/((343/954)*100),
                                      V670 == 2 ~ ((40.81/115.65)*100)/((144/954)*100),
                                      V670 == 3 ~ ((15.65/115.65)*100)/((321/954)*100),
                                      V670 == 4 ~ ((13.48/115.65)*100)/((141/954)*100),
                                      V670 == 5 ~ ((2.170/115.65)*100)/((5/954)*100)))
DE$w8 <- DE$w8eth*DE$w8gen*DE$w8edu*DE$w8reg*DE$w8urb
DE  <- mutate(DE, w8 = ifelse(is.na(w8), 1, w8))
#NL
NL <- NL %>% mutate(w8eth = case_when(NL$catraceNLb == "Dutch" ~ 2.346212,
                                      NL$catraceNLb == "Morocco" ~ 0.1340415,
                                      NL$catraceNLb == "Turkey" ~ 0.1026367,
                                      NL$catraceNLb == "Surinam" ~ 0.07831423,
                                      NL$catraceNLb == "Other" ~ 1))
NL <- NL %>% mutate(OPL2 = case_when(NL$OPL == 1 ~ "below upper secondary",
                                     NL$OPL == 2 ~ "below upper secondary",
                                     NL$OPL == 3 ~ "below upper secondary",
                                     NL$OPL == 4 ~ "upper secondary",
                                     NL$OPL == 5 ~ "upper secondary",
                                     NL$OPL == 6 ~ "upper secondary",
                                     NL$OPL == 7 ~ "tertiary"))
NL <- NL %>% mutate(w8edu = case_when(NL$OPL2 == "below upper secondary" ~ 1.301712,
                                      NL$OPL2 == "upper secondary" ~ 0.589336,
                                      NL$OPL2 == "tertiary" ~ 2.864586))
NL <- NL %>% mutate(w8gen = case_when(NL$Female == 1 ~ 0.9299617,
                                      NL$Female == 0 ~ 1.082329))
NL <- NL %>% mutate(w8reg = case_when(PROVINCIE == 1 ~  ((585866/17407585)*100)/((21/905)*100),
                                      PROVINCIE == 2 ~  ((649957/17407585)*100)/((20/905)*100),
                                      PROVINCIE == 3 ~  ((493682/17407585)*100)/((18/905)*100),
                                      PROVINCIE == 4 ~  ((1162406/17407585)*100)/((58/905)*100),
                                      PROVINCIE == 5 ~  ((2085952/17407585)*100)/((73/905)*100),
                                      PROVINCIE == 6 ~  ((1354834/17407585)*100)/((76/905)*100),
                                      PROVINCIE == 7 ~  ((2879527/17407585)*100)/((198/905)*100),
                                      PROVINCIE == 8 ~  ((3708696/17407585)*100)/((253/905)*100),
                                      PROVINCIE == 9 ~  ((383488/17407585)*100)/((9/905)*100),
                                      PROVINCIE == 10 ~ ((423021/17407585)*100)/((36/905)*100),
                                      PROVINCIE == 11 ~ ((2562955/17407585)*100)/((96/905)*100),
                                      PROVINCIE == 12 ~ ((1117201/17407585)*100)/((47/905)*100)))
NL <- NL %>% mutate(w8urb = case_when(STED_GM == 1 ~ ((74.22/101.22)*100)/((334/905)*100),
                                      STED_GM == 2 ~ ((25.17/101.22)*100)/((313/905)*100),
                                      STED_GM == 3 ~ ((0.61/101.22)*100)/((116/905)*100),
                                      STED_GM == 4 ~ ((0.61/101.22)*100)/((105/905)*100),
                                      STED_GM == 5 ~ ((0.61/101.22)*100)/((37/905)*100)))
NL$w8 <- NL$w8eth*NL$w8gen*NL$w8edu*NL$w8reg*NL$w8urb
NL  <- mutate(NL, w8 = ifelse(is.na(w8), 1, w8))

#-----------------------------#
#--- Different or the same ---#
#-----------------------------#

#FR
FR$V479_1 #native French people
FR$V479_2 #French North-African people
FR$V479_3 #French Sub-Saharan African people
FR$V479_4 #French Turkish people
FR$V479_5 #People who practice Islam
FR$V479_6 #People who practice Christianity
FR$V479_7 #People who do not practice any religion

FR <- FR %>% mutate(Diff.Nat = case_when(V479_1 == 1 ~ 10,
                                         V479_1 == 2 ~ 9,
                                         V479_1 == 3 ~ 8,
                                         V479_1 == 4 ~ 7,
                                         V479_1 == 5 ~ 6,
                                         V479_1 == 6 ~ 5,
                                         V479_1 == 7 ~ 4,
                                         V479_1 == 8 ~ 3,
                                         V479_1 == 9 ~ 2,
                                         V479_1 == 10 ~ 1,
                                         V479_1 == 11 ~ 0))

FR <- FR %>% mutate(Diff.Mag = case_when(V479_2 == 1 ~ 10,
                                         V479_2 == 2 ~ 9,
                                         V479_2 == 3 ~ 8,
                                         V479_2 == 4 ~ 7,
                                         V479_2 == 5 ~ 6,
                                         V479_2 == 6 ~ 5,
                                         V479_2 == 7 ~ 4,
                                         V479_2 == 8 ~ 3,
                                         V479_2 == 9 ~ 2,
                                         V479_2 == 10 ~ 1,
                                         V479_2 == 11 ~ 0))

FR <- FR %>% mutate(Diff.Sub = case_when(V479_3 == 1 ~ 10,
                                         V479_3 == 2 ~ 9,
                                         V479_3 == 3 ~ 8,
                                         V479_3 == 4 ~ 7,
                                         V479_3 == 5 ~ 6,
                                         V479_3 == 6 ~ 5,
                                         V479_3 == 7 ~ 4,
                                         V479_3 == 8 ~ 3,
                                         V479_3 == 9 ~ 2,
                                         V479_3 == 10 ~ 1,
                                         V479_3 == 11 ~ 0))

FR <- FR %>% mutate(Diff.Tur = case_when(V479_4 == 1 ~ 10,
                                         V479_4 == 2 ~ 9,
                                         V479_4 == 3 ~ 8,
                                         V479_4 == 4 ~ 7,
                                         V479_4 == 5 ~ 6,
                                         V479_4 == 6 ~ 5,
                                         V479_4 == 7 ~ 4,
                                         V479_4 == 8 ~ 3,
                                         V479_4 == 9 ~ 2,
                                         V479_4 == 10 ~ 1,
                                         V479_4 == 11 ~ 0))

FR <- FR %>% mutate(Diff.Muslims = case_when(V479_5 == 1 ~ 10,
                                             V479_5 == 2 ~ 9,
                                             V479_5 == 3 ~ 8,
                                             V479_5 == 4 ~ 7,
                                             V479_5 == 5 ~ 6,
                                             V479_5 == 6 ~ 5,
                                             V479_5 == 7 ~ 4,
                                             V479_5 == 8 ~ 3,
                                             V479_5 == 9 ~ 2,
                                             V479_5 == 10 ~ 1,
                                             V479_5 == 11 ~ 0))

FR <- FR %>% mutate(Diff.Christians = case_when(V479_6 == 1 ~ 10,
                                                V479_6 == 2 ~ 9,
                                                V479_6 == 3 ~ 8,
                                                V479_6 == 4 ~ 7,
                                                V479_6 == 5 ~ 6,
                                                V479_6 == 6 ~ 5,
                                                V479_6 == 7 ~ 4,
                                                V479_6 == 8 ~ 3,
                                                V479_6 == 9 ~ 2,
                                                V479_6 == 10 ~ 1,
                                                V479_6 == 11 ~ 0))

FR <- FR %>% mutate(Diff.Nonrelig = case_when(V479_7 == 1 ~ 10,
                                              V479_7 == 2 ~ 9,
                                              V479_7 == 3 ~ 8,
                                              V479_7 == 4 ~ 7,
                                              V479_7 == 5 ~ 6,
                                              V479_7 == 6 ~ 5,
                                              V479_7 == 7 ~ 4,
                                              V479_7 == 8 ~ 3,
                                              V479_7 == 9 ~ 2,
                                              V479_7 == 10 ~ 1,
                                              V479_7 == 11 ~ 0))

#DE
DE$V479_1 #native German people
DE$V479_2 #German Turkish people
DE$V479_3 #German Former Soviet Union people
DE$V479_4 #People who practice Islam
DE$V479_5 #People who practice Christianity
DE$V479_6 #People who do not practice any religion

DE <- DE %>% mutate(Diff.Nat = case_when(V479_1 == 1 ~ 10,
                                         V479_1 == 2 ~ 9,
                                         V479_1 == 3 ~ 8,
                                         V479_1 == 4 ~ 7,
                                         V479_1 == 5 ~ 6,
                                         V479_1 == 6 ~ 5,
                                         V479_1 == 7 ~ 4,
                                         V479_1 == 8 ~ 3,
                                         V479_1 == 9 ~ 2,
                                         V479_1 == 10 ~ 1,
                                         V479_1 == 11 ~ 0))

DE <- DE %>% mutate(Diff.Tur = case_when(V479_2 == 1 ~ 10,
                                         V479_2 == 2 ~ 9,
                                         V479_2 == 3 ~ 8,
                                         V479_2 == 4 ~ 7,
                                         V479_2 == 5 ~ 6,
                                         V479_2 == 6 ~ 5,
                                         V479_2 == 7 ~ 4,
                                         V479_2 == 8 ~ 3,
                                         V479_2 == 9 ~ 2,
                                         V479_2 == 10 ~ 1,
                                         V479_2 == 11 ~ 0))

DE <- DE %>% mutate(Diff.FSU = case_when(V479_3 == 1 ~ 10,
                                         V479_3 == 2 ~ 9,
                                         V479_3 == 3 ~ 8,
                                         V479_3 == 4 ~ 7,
                                         V479_3 == 5 ~ 6,
                                         V479_3 == 6 ~ 5,
                                         V479_3 == 7 ~ 4,
                                         V479_3 == 8 ~ 3,
                                         V479_3 == 9 ~ 2,
                                         V479_3 == 10 ~ 1,
                                         V479_3 == 11 ~ 0))

DE <- DE %>% mutate(Diff.Muslims = case_when(V479_4 == 1 ~ 10,
                                             V479_4 == 2 ~ 9,
                                             V479_4 == 3 ~ 8,
                                             V479_4 == 4 ~ 7,
                                             V479_4 == 5 ~ 6,
                                             V479_4 == 6 ~ 5,
                                             V479_4 == 7 ~ 4,
                                             V479_4 == 8 ~ 3,
                                             V479_4 == 9 ~ 2,
                                             V479_4 == 10 ~ 1,
                                             V479_4 == 11 ~ 0))

DE <- DE %>% mutate(Diff.Christians = case_when(V479_5 == 1 ~ 10,
                                                V479_5 == 2 ~ 9,
                                                V479_5 == 3 ~ 8,
                                                V479_5 == 4 ~ 7,
                                                V479_5 == 5 ~ 6,
                                                V479_5 == 6 ~ 5,
                                                V479_5 == 7 ~ 4,
                                                V479_5 == 8 ~ 3,
                                                V479_5 == 9 ~ 2,
                                                V479_5 == 10 ~ 1,
                                                V479_5 == 11 ~ 0))

DE <- DE %>% mutate(Diff.Nonrelig = case_when(V479_6 == 1 ~ 10,
                                              V479_6 == 2 ~ 9,
                                              V479_6 == 3 ~ 8,
                                              V479_6 == 4 ~ 7,
                                              V479_6 == 5 ~ 6,
                                              V479_6 == 6 ~ 5,
                                              V479_6 == 7 ~ 4,
                                              V479_6 == 8 ~ 3,
                                              V479_6 == 9 ~ 2,
                                              V479_6 == 10 ~ 1,
                                              V479_6 == 11 ~ 0))

#NL
NL$V479_1 #native Dutch people
NL$V479_2 #Dutch Moroccan people
NL$V479_3 #Dutch Surinamese people
NL$V479_4 #Dutch Turkish people
NL$V479_5 #People who practice Islam
NL$V479_6 #People who practice Christianity
NL$V479_7 #People who do not practice any religion

NL <- NL %>% mutate(Diff.Nat = case_when(V479_1 == 1 ~ 10,
                                         V479_1 == 2 ~ 9,
                                         V479_1 == 3 ~ 8,
                                         V479_1 == 4 ~ 7,
                                         V479_1 == 5 ~ 6,
                                         V479_1 == 6 ~ 5,
                                         V479_1 == 7 ~ 4,
                                         V479_1 == 8 ~ 3,
                                         V479_1 == 9 ~ 2,
                                         V479_1 == 10 ~ 1,
                                         V479_1 == 11 ~ 0))

NL <- NL %>% mutate(Diff.Mor = case_when(V479_2 == 1 ~ 10,
                                         V479_2 == 2 ~ 9,
                                         V479_2 == 3 ~ 8,
                                         V479_2 == 4 ~ 7,
                                         V479_2 == 5 ~ 6,
                                         V479_2 == 6 ~ 5,
                                         V479_2 == 7 ~ 4,
                                         V479_2 == 8 ~ 3,
                                         V479_2 == 9 ~ 2,
                                         V479_2 == 10 ~ 1,
                                         V479_2 == 11 ~ 0))

NL <- NL %>% mutate(Diff.Sur = case_when(V479_3 == 1 ~ 10,
                                         V479_3 == 2 ~ 9,
                                         V479_3 == 3 ~ 8,
                                         V479_3 == 4 ~ 7,
                                         V479_3 == 5 ~ 6,
                                         V479_3 == 6 ~ 5,
                                         V479_3 == 7 ~ 4,
                                         V479_3 == 8 ~ 3,
                                         V479_3 == 9 ~ 2,
                                         V479_3 == 10 ~ 1,
                                         V479_3 == 11 ~ 0))

NL <- NL %>% mutate(Diff.Tur = case_when(V479_4 == 1 ~ 10,
                                         V479_4 == 2 ~ 9,
                                         V479_4 == 3 ~ 8,
                                         V479_4 == 4 ~ 7,
                                         V479_4 == 5 ~ 6,
                                         V479_4 == 6 ~ 5,
                                         V479_4 == 7 ~ 4,
                                         V479_4 == 8 ~ 3,
                                         V479_4 == 9 ~ 2,
                                         V479_4 == 10 ~ 1,
                                         V479_4 == 11 ~ 0))

NL <- NL %>% mutate(Diff.Muslims = case_when(V479_5 == 1 ~ 10,
                                             V479_5 == 2 ~ 9,
                                             V479_5 == 3 ~ 8,
                                             V479_5 == 4 ~ 7,
                                             V479_5 == 5 ~ 6,
                                             V479_5 == 6 ~ 5,
                                             V479_5 == 7 ~ 4,
                                             V479_5 == 8 ~ 3,
                                             V479_5 == 9 ~ 2,
                                             V479_5 == 10 ~ 1,
                                             V479_5 == 11 ~ 0))

NL <- NL %>% mutate(Diff.Christians = case_when(V479_6 == 1 ~ 10,
                                                V479_6 == 2 ~ 9,
                                                V479_6 == 3 ~ 8,
                                                V479_6 == 4 ~ 7,
                                                V479_6 == 5 ~ 6,
                                                V479_6 == 6 ~ 5,
                                                V479_6 == 7 ~ 4,
                                                V479_6 == 8 ~ 3,
                                                V479_6 == 9 ~ 2,
                                                V479_6 == 10 ~ 1,
                                                V479_6 == 11 ~ 0))

NL <- NL %>% mutate(Diff.Nonrelig = case_when(V479_7 == 1 ~ 10,
                                              V479_7 == 2 ~ 9,
                                              V479_7 == 3 ~ 8,
                                              V479_7 == 4 ~ 7,
                                              V479_7 == 5 ~ 6,
                                              V479_7 == 6 ~ 5,
                                              V479_7 == 7 ~ 4,
                                              V479_7 == 8 ~ 3,
                                              V479_7 == 9 ~ 2,
                                              V479_7 == 10 ~ 1,
                                              V479_7 == 11 ~ 0))

#------------------#
#--- PTV-scores ---#
#------------------#

#FR
FR <- FR %>% mutate(lik2votLREM = case_when(V269_1 == 1 ~ 0,
                                            V269_1 == 2 ~ 0.1,
                                            V269_1 == 3 ~ 0.2,
                                            V269_1 == 4 ~ 0.3,
                                            V269_1 == 5 ~ 0.4,
                                            V269_1 == 6 ~ 0.5,
                                            V269_1 == 7 ~ 0.6,
                                            V269_1 == 8 ~ 0.7,
                                            V269_1 == 9 ~ 0.8,
                                            V269_1 == 10 ~ 0.9,
                                            V269_1 == 11 ~ 1))
FR <- FR %>% mutate(lik2votLR = case_when(V269_2 == 1 ~ 0,
                                          V269_2 == 2 ~ 0.1,
                                          V269_2 == 3 ~ 0.2,
                                          V269_2 == 4 ~ 0.3,
                                          V269_2 == 5 ~ 0.4,
                                          V269_2 == 6 ~ 0.5,
                                          V269_2 == 7 ~ 0.6,
                                          V269_2 == 8 ~ 0.7,
                                          V269_2 == 9 ~ 0.8,
                                          V269_2 == 10 ~ 0.9,
                                          V269_2 == 11 ~ 1))
FR <- FR %>% mutate(lik2votPS = case_when(V269_3 == 1 ~ 0,
                                          V269_3 == 2 ~ 0.1,
                                          V269_3 == 3 ~ 0.2,
                                          V269_3 == 4 ~ 0.3,
                                          V269_3 == 5 ~ 0.4,
                                          V269_3 == 6 ~ 0.5,
                                          V269_3 == 7 ~ 0.6,
                                          V269_3 == 8 ~ 0.7,
                                          V269_3 == 9 ~ 0.8,
                                          V269_3 == 10 ~ 0.9,
                                          V269_3 == 11 ~ 1))
FR <- FR %>% mutate(lik2votMoDem = case_when(V269_4 == 1 ~ 0,
                                             V269_4 == 2 ~ 0.1,
                                             V269_4 == 3 ~ 0.2,
                                             V269_4 == 4 ~ 0.3,
                                             V269_4 == 5 ~ 0.4,
                                             V269_4 == 6 ~ 0.5,
                                             V269_4 == 7 ~ 0.6,
                                             V269_4 == 8 ~ 0.7,
                                             V269_4 == 9 ~ 0.8,
                                             V269_4 == 10 ~ 0.9,
                                             V269_4 == 11 ~ 1))
FR <- FR %>% mutate(lik2votFI = case_when(V269_5 == 1 ~ 0,
                                          V269_5 == 2 ~ 0.1,
                                          V269_5 == 3 ~ 0.2,
                                          V269_5 == 4 ~ 0.3,
                                          V269_5 == 5 ~ 0.4,
                                          V269_5 == 6 ~ 0.5,
                                          V269_5 == 7 ~ 0.6,
                                          V269_5 == 8 ~ 0.7,
                                          V269_5 == 9 ~ 0.8,
                                          V269_5 == 10 ~ 0.9,
                                          V269_5 == 11 ~ 1))
FR <- FR %>% mutate(lik2votPCF = case_when(V269_6 == 1 ~ 0,
                                           V269_6 == 2 ~ 0.1,
                                           V269_6 == 3 ~ 0.2,
                                           V269_6 == 4 ~ 0.3,
                                           V269_6 == 5 ~ 0.4,
                                           V269_6 == 6 ~ 0.5,
                                           V269_6 == 7 ~ 0.6,
                                           V269_6 == 8 ~ 0.7,
                                           V269_6 == 9 ~ 0.8,
                                           V269_6 == 10 ~ 0.9,
                                           V269_6 == 11 ~ 1))
FR <- FR %>% mutate(lik2votRN = case_when(V269_7 == 1 ~ 0,
                                          V269_7 == 2 ~ 0.1,
                                          V269_7 == 3 ~ 0.2,
                                          V269_7 == 4 ~ 0.3,
                                          V269_7 == 5 ~ 0.4,
                                          V269_7 == 6 ~ 0.5,
                                          V269_7 == 7 ~ 0.6,
                                          V269_7 == 8 ~ 0.7,
                                          V269_7 == 9 ~ 0.8,
                                          V269_7 == 10 ~ 0.9,
                                          V269_7 == 11 ~ 1))
FR <- FR %>% mutate(lik2votMR = case_when(V269_8 == 1 ~ 0,
                                          V269_8 == 2 ~ 0.1,
                                          V269_8 == 3 ~ 0.2,
                                          V269_8 == 4 ~ 0.3,
                                          V269_8 == 5 ~ 0.4,
                                          V269_8 == 6 ~ 0.5,
                                          V269_8 == 7 ~ 0.6,
                                          V269_8 == 8 ~ 0.7,
                                          V269_8 == 9 ~ 0.8,
                                          V269_8 == 10 ~ 0.9,
                                          V269_8 == 11 ~ 1))

#DE
DE <- DE %>% mutate(lik2votCDU = case_when(V269_1 == 1 ~ 0,
                                           V269_1 == 2 ~ 0.1,
                                           V269_1 == 3 ~ 0.2,
                                           V269_1 == 4 ~ 0.3,
                                           V269_1 == 5 ~ 0.4,
                                           V269_1 == 6 ~ 0.5,
                                           V269_1 == 7 ~ 0.6,
                                           V269_1 == 8 ~ 0.7,
                                           V269_1 == 9 ~ 0.8,
                                           V269_1 == 10 ~ 0.9,
                                           V269_1 == 11 ~ 1))
DE <- DE %>% mutate(lik2votSDP = case_when(V269_2 == 1 ~ 0,
                                           V269_2 == 2 ~ 0.1,
                                           V269_2 == 3 ~ 0.2,
                                           V269_2 == 4 ~ 0.3,
                                           V269_2 == 5 ~ 0.4,
                                           V269_2 == 6 ~ 0.5,
                                           V269_2 == 7 ~ 0.6,
                                           V269_2 == 8 ~ 0.7,
                                           V269_2 == 9 ~ 0.8,
                                           V269_2 == 10 ~ 0.9,
                                           V269_2 == 11 ~ 1))
DE <- DE %>% mutate(lik2votAfD = case_when(V269_3 == 1 ~ 0,
                                           V269_3 == 2 ~ 0.1,
                                           V269_3 == 3 ~ 0.2,
                                           V269_3 == 4 ~ 0.3,
                                           V269_3 == 5 ~ 0.4,
                                           V269_3 == 6 ~ 0.5,
                                           V269_3 == 7 ~ 0.6,
                                           V269_3 == 8 ~ 0.7,
                                           V269_3 == 9 ~ 0.8,
                                           V269_3 == 10 ~ 0.9,
                                           V269_3 == 11 ~ 1))
DE <- DE %>% mutate(lik2votFDP = case_when(V269_4 == 1 ~ 0,
                                           V269_4 == 2 ~ 0.1,
                                           V269_4 == 3 ~ 0.2,
                                           V269_4 == 4 ~ 0.3,
                                           V269_4 == 5 ~ 0.4,
                                           V269_4 == 6 ~ 0.5,
                                           V269_4 == 7 ~ 0.6,
                                           V269_4 == 8 ~ 0.7,
                                           V269_4 == 9 ~ 0.8,
                                           V269_4 == 10 ~ 0.9,
                                           V269_4 == 11 ~ 1))
DE <- DE %>% mutate(lik2votDieLinke = case_when(V269_5 == 1 ~ 0,
                                                V269_5 == 2 ~ 0.1,
                                                V269_5 == 3 ~ 0.2,
                                                V269_5 == 4 ~ 0.3,
                                                V269_5 == 5 ~ 0.4,
                                                V269_5 == 6 ~ 0.5,
                                                V269_5 == 7 ~ 0.6,
                                                V269_5 == 8 ~ 0.7,
                                                V269_5 == 9 ~ 0.8,
                                                V269_5 == 10 ~ 0.9,
                                                V269_5 == 11 ~ 1))
DE <- DE %>% mutate(lik2votGrune = case_when(V269_6 == 1 ~ 0,
                                             V269_6 == 2 ~ 0.1,
                                             V269_6 == 3 ~ 0.2,
                                             V269_6 == 4 ~ 0.3,
                                             V269_6 == 5 ~ 0.4,
                                             V269_6 == 6 ~ 0.5,
                                             V269_6 == 7 ~ 0.6,
                                             V269_6 == 8 ~ 0.7,
                                             V269_6 == 9 ~ 0.8,
                                             V269_6 == 10 ~ 0.9,
                                             V269_6 == 11 ~ 1))
DE <- DE %>% mutate(lik2votCSU = case_when(V269_7 == 1 ~ 0,
                                           V269_7 == 2 ~ 0.1,
                                           V269_7 == 3 ~ 0.2,
                                           V269_7 == 4 ~ 0.3,
                                           V269_7 == 5 ~ 0.4,
                                           V269_7 == 6 ~ 0.5,
                                           V269_7 == 7 ~ 0.6,
                                           V269_7 == 8 ~ 0.7,
                                           V269_7 == 9 ~ 0.8,
                                           V269_7 == 10 ~ 0.9,
                                           V269_7 == 11 ~ 1))

#NL
NL <- NL %>% mutate(lik2votCDA = case_when(V269_1 == 1 ~ 0,
                                           V269_1 == 2 ~ 0.1,
                                           V269_1 == 3 ~ 0.2,
                                           V269_1 == 4 ~ 0.3,
                                           V269_1 == 5 ~ 0.4,
                                           V269_1 == 6 ~ 0.5,
                                           V269_1 == 7 ~ 0.6,
                                           V269_1 == 8 ~ 0.7,
                                           V269_1 == 9 ~ 0.8,
                                           V269_1 == 10 ~ 0.9,
                                           V269_1 == 11 ~ 1))
NL <- NL %>% mutate(lik2votCU = case_when(V269_2 == 1 ~ 0,
                                          V269_2 == 2 ~ 0.1,
                                          V269_2 == 3 ~ 0.2,
                                          V269_2 == 4 ~ 0.3,
                                          V269_2 == 5 ~ 0.4,
                                          V269_2 == 6 ~ 0.5,
                                          V269_2 == 7 ~ 0.6,
                                          V269_2 == 8 ~ 0.7,
                                          V269_2 == 9 ~ 0.8,
                                          V269_2 == 10 ~ 0.9,
                                          V269_2 == 11 ~ 1))
NL <- NL %>% mutate(lik2votD66 = case_when(V269_3 == 1 ~ 0,
                                           V269_3 == 2 ~ 0.1,
                                           V269_3 == 3 ~ 0.2,
                                           V269_3 == 4 ~ 0.3,
                                           V269_3 == 5 ~ 0.4,
                                           V269_3 == 6 ~ 0.5,
                                           V269_3 == 7 ~ 0.6,
                                           V269_3 == 8 ~ 0.7,
                                           V269_3 == 9 ~ 0.8,
                                           V269_3 == 10 ~ 0.9,
                                           V269_3 == 11 ~ 1))
NL <- NL %>% mutate(lik2votDENK = case_when(V269_4 == 1 ~ 0,
                                            V269_4 == 2 ~ 0.1,
                                            V269_4 == 3 ~ 0.2,
                                            V269_4 == 4 ~ 0.3,
                                            V269_4 == 5 ~ 0.4,
                                            V269_4 == 6 ~ 0.5,
                                            V269_4 == 7 ~ 0.6,
                                            V269_4 == 8 ~ 0.7,
                                            V269_4 == 9 ~ 0.8,
                                            V269_4 == 10 ~ 0.9,
                                            V269_4 == 11 ~ 1))
NL <- NL %>% mutate(lik2votFvD = case_when(V269_5 == 1 ~ 0,
                                           V269_5 == 2 ~ 0.1,
                                           V269_5 == 3 ~ 0.2,
                                           V269_5 == 4 ~ 0.3,
                                           V269_5 == 5 ~ 0.4,
                                           V269_5 == 6 ~ 0.5,
                                           V269_5 == 7 ~ 0.6,
                                           V269_5 == 8 ~ 0.7,
                                           V269_5 == 9 ~ 0.8,
                                           V269_5 == 10 ~ 0.9,
                                           V269_5 == 11 ~ 1))
NL <- NL %>% mutate(lik2votGL = case_when(V269_6 == 1 ~ 0,
                                          V269_6 == 2 ~ 0.1,
                                          V269_6 == 3 ~ 0.2,
                                          V269_6 == 4 ~ 0.3,
                                          V269_6 == 5 ~ 0.4,
                                          V269_6 == 6 ~ 0.5,
                                          V269_6 == 7 ~ 0.6,
                                          V269_6 == 8 ~ 0.7,
                                          V269_6 == 9 ~ 0.8,
                                          V269_6 == 10 ~ 0.9,
                                          V269_6 == 11 ~ 1))
NL <- NL %>% mutate(lik2votPvdA = case_when(V269_7 == 1 ~ 0,
                                            V269_7 == 2 ~ 0.1,
                                            V269_7 == 3 ~ 0.2,
                                            V269_7 == 4 ~ 0.3,
                                            V269_7 == 5 ~ 0.4,
                                            V269_7 == 6 ~ 0.5,
                                            V269_7 == 7 ~ 0.6,
                                            V269_7 == 8 ~ 0.7,
                                            V269_7 == 9 ~ 0.8,
                                            V269_7 == 10 ~ 0.9,
                                            V269_7 == 11 ~ 1))
NL <- NL %>% mutate(lik2votPvdD = case_when(V269_8 == 1 ~ 0,
                                            V269_8 == 2 ~ 0.1,
                                            V269_8 == 3 ~ 0.2,
                                            V269_8 == 4 ~ 0.3,
                                            V269_8 == 5 ~ 0.4,
                                            V269_8 == 6 ~ 0.5,
                                            V269_8 == 7 ~ 0.6,
                                            V269_8 == 8 ~ 0.7,
                                            V269_8 == 9 ~ 0.8,
                                            V269_8 == 10 ~ 0.9,
                                            V269_8 == 11 ~ 1))
NL <- NL %>% mutate(lik2votPVV = case_when(V269_9 == 1 ~ 0,
                                           V269_9 == 2 ~ 0.1,
                                           V269_9 == 3 ~ 0.2,
                                           V269_9 == 4 ~ 0.3,
                                           V269_9 == 5 ~ 0.4,
                                           V269_9 == 6 ~ 0.5,
                                           V269_9 == 7 ~ 0.6,
                                           V269_9 == 8 ~ 0.7,
                                           V269_9 == 9 ~ 0.8,
                                           V269_9 == 10 ~ 0.9,
                                           V269_9 == 11 ~ 1))
NL <- NL %>% mutate(lik2votSGP = case_when(V269_10 == 1 ~ 0,
                                           V269_10 == 2 ~ 0.1,
                                           V269_10 == 3 ~ 0.2,
                                           V269_10 == 4 ~ 0.3,
                                           V269_10 == 5 ~ 0.4,
                                           V269_10 == 6 ~ 0.5,
                                           V269_10 == 7 ~ 0.6,
                                           V269_10 == 8 ~ 0.7,
                                           V269_10 == 9 ~ 0.8,
                                           V269_10 == 10 ~ 0.9,
                                           V269_10 == 11 ~ 1))
NL <- NL %>% mutate(lik2votSP = case_when(V269_11 == 1 ~ 0,
                                          V269_11 == 2 ~ 0.1,
                                          V269_11 == 3 ~ 0.2,
                                          V269_11 == 4 ~ 0.3,
                                          V269_11 == 5 ~ 0.4,
                                          V269_11 == 6 ~ 0.5,
                                          V269_11 == 7 ~ 0.6,
                                          V269_11 == 8 ~ 0.7,
                                          V269_11 == 9 ~ 0.8,
                                          V269_11 == 10 ~ 0.9,
                                          V269_11 == 11 ~ 1))
NL <- NL %>% mutate(lik2votVVD = case_when(V269_12 == 1 ~ 0,
                                           V269_12 == 2 ~ 0.1,
                                           V269_12 == 3 ~ 0.2,
                                           V269_12 == 4 ~ 0.3,
                                           V269_12 == 5 ~ 0.4,
                                           V269_12 == 6 ~ 0.5,
                                           V269_12 == 7 ~ 0.6,
                                           V269_12 == 8 ~ 0.7,
                                           V269_12 == 9 ~ 0.8,
                                           V269_12 == 10 ~ 0.9,
                                           V269_12 == 11 ~ 1))
NL <- NL %>% mutate(lik2vot50p = case_when(V269_13 == 1 ~ 0,
                                           V269_13 == 2 ~ 0.1,
                                           V269_13 == 3 ~ 0.2,
                                           V269_13 == 4 ~ 0.3,
                                           V269_13 == 5 ~ 0.4,
                                           V269_13 == 6 ~ 0.5,
                                           V269_13 == 7 ~ 0.6,
                                           V269_13 == 8 ~ 0.7,
                                           V269_13 == 9 ~ 0.8,
                                           V269_13 == 10 ~ 0.9,
                                           V269_13 == 11 ~ 1))

#install.packages("ltm")
library("ltm")

#FR
FR$CAcenter <- data.frame(FR$lik2votLREM,FR$lik2votMoDem,FR$lik2votMR)
ltm::cronbach.alpha(FR$CAcenter)

FR$CArad.le <- data.frame(FR$lik2votFI,FR$lik2votPCF)
ltm::cronbach.alpha(FR$CArad.le)

FR$rad.ri <- FR$lik2votRN
FR$cen.ri <- FR$lik2votLR
FR$center <- (FR$lik2votLREM + FR$lik2votMoDem + FR$lik2votMR)/2
FR$cen.le <- FR$lik2votPS
FR$rad.le <- (FR$lik2votFI + FR$lik2votPCF)/2

#DE
DE$CAcen.ri <- data.frame(DE$lik2votCDU,DE$lik2votCSU)
ltm::cronbach.alpha(DE$CAcen.ri)

DE$CAcen.le <- data.frame(DE$lik2votDieLinke,DE$lik2votSDP)
ltm::cronbach.alpha(DE$CAcen.le)

DE$rad.ri <- DE$lik2votAfD
DE$cen.ri <- (DE$lik2votCDU + DE$lik2votCSU)/2
DE$center <- DE$lik2votFDP
DE$cen.le <- DE$lik2votSDP 
DE$rad.le <- DE$lik2votDieLinke

#NL
NL$CArad.ri <- data.frame(NL$lik2votPVV,NL$lik2votFvD)
ltm::cronbach.alpha(NL$CArad.ri)

NL$CAchr.de <- data.frame(NL$lik2votCU,NL$lik2votCDA,NL$lik2votSGP,NL$lik2votVVD)
ltm::cronbach.alpha(NL$CAchr.de)

NL$rad.ri <- (NL$lik2votPVV + NL$lik2votFvD)/2
NL$cen.ri <- (NL$lik2votCDA + NL$lik2votCU + NL$lik2votSGP + NL$lik2votVVD)/4
NL$center <- NL$lik2votD66
NL$cen.le <- NL$lik2votPvdA
NL$rad.le <- NL$lik2votSP

#--------------------------------------#
#--- table 4 descriptive statistics ---#
#--------------------------------------#

FR <- FR %>% mutate(cntry = case_when(FR$INTNR > 0 ~ "France"))
DE <- DE %>% mutate(cntry = case_when(DE$INTNR > 0 ~ "Germany"))
NL <- NL %>% mutate(cntry = case_when(NL$INTNR > 0 ~ "Netherlands"))

#make new variables so they can be merged
DE <- DE %>% mutate(catMag = case_when(INTNR == 0 ~ "x"))
NL <- NL %>% mutate(catMag = case_when(INTNR == 0 ~ "x"))
DE <- DE %>% mutate(catSSA = case_when(INTNR == 0 ~ "x"))
NL <- NL %>% mutate(catSSA = case_when(INTNR == 0 ~ "x"))
FR <- FR %>% mutate(catFSU = case_when(INTNR == 0 ~ "x"))
NL <- NL %>% mutate(catFSU = case_when(INTNR == 0 ~ "x"))
DE <- DE %>% mutate(catMor = case_when(INTNR == 0 ~ "x"))
FR <- FR %>% mutate(catMor = case_when(INTNR == 0 ~ "x"))
DE <- DE %>% mutate(catSur = case_when(INTNR == 0 ~ "x"))
FR <- FR %>% mutate(catSur = case_when(INTNR == 0 ~ "x"))

DE <- DE %>% mutate(prof.exp.Mag.1st = case_when(INTNR == 0 ~ "x"))
NL <- NL %>% mutate(prof.exp.Mag.1st = case_when(INTNR == 0 ~ "x"))
DE <- DE %>% mutate(prof.exp.SSA.1st = case_when(INTNR == 0 ~ "x"))
NL <- NL %>% mutate(prof.exp.SSA.1st = case_when(INTNR == 0 ~ "x"))
FR <- FR %>% mutate(prof.exp.FSU.1st = case_when(INTNR == 0 ~ "x"))
NL <- NL %>% mutate(prof.exp.FSU.1st = case_when(INTNR == 0 ~ "x"))
DE <- DE %>% mutate(prof.exp.Mor.1st = case_when(INTNR == 0 ~ "x"))
FR <- FR %>% mutate(prof.exp.Mor.1st = case_when(INTNR == 0 ~ "x"))
DE <- DE %>% mutate(prof.exp.Sur.1st = case_when(INTNR == 0 ~ "x"))
FR <- FR %>% mutate(prof.exp.Sur.1st = case_when(INTNR == 0 ~ "x"))

DE <- DE %>% mutate(prof.exp.Mag.2nd = case_when(INTNR == 0 ~ "x"))
NL <- NL %>% mutate(prof.exp.Mag.2nd = case_when(INTNR == 0 ~ "x"))
DE <- DE %>% mutate(prof.exp.SSA.2nd = case_when(INTNR == 0 ~ "x"))
NL <- NL %>% mutate(prof.exp.SSA.2nd = case_when(INTNR == 0 ~ "x"))
FR <- FR %>% mutate(prof.exp.FSU.2nd = case_when(INTNR == 0 ~ "x"))
NL <- NL %>% mutate(prof.exp.FSU.2nd = case_when(INTNR == 0 ~ "x"))
DE <- DE %>% mutate(prof.exp.Mor.2nd = case_when(INTNR == 0 ~ "x"))
FR <- FR %>% mutate(prof.exp.Mor.2nd = case_when(INTNR == 0 ~ "x"))
DE <- DE %>% mutate(prof.exp.Sur.2nd = case_when(INTNR == 0 ~ "x"))
FR <- FR %>% mutate(prof.exp.Sur.2nd = case_when(INTNR == 0 ~ "x"))

#new datasets with all the same variable names
#FR
eFR <- as_tibble(FR$INTNR) 
names(eFR) <- "INTNR"
eFR$cntry <- FR$cntry

eFR$MigBckGrnd <- FR$catrace
eFR$binidrel2 <- FR$binidrel2
eFR$relMus <- FR$relMus
eFR$relChr <- FR$relChr
eFR$relOth <- FR$relOth
eFR$relNon <- FR$relNon

eFR$Female <- FR$Female
eFR$Education <- FR$Education 
eFR$Age <- FR$Age
eFR$AGE2 <- FR$AGE2
eFR$w8 <- FR$w8

#PTV
eFR$rad.ri <- FR$rad.ri
eFR$cen.ri <- FR$cen.ri
eFR$center <- FR$center
eFR$cen.le <- FR$cen.le 
eFR$rad.le <- FR$rad.le 

#different or same
eFR$Diff.Nat <- FR$Diff.Nat
eFR$Diff.Tur <- FR$Diff.Tur
eFR$Diff.Muslims <- FR$Diff.Muslims
eFR$Diff.Christians <- FR$Diff.Christians
eFR$Diff.Nonrelig <- FR$Diff.Nonrelig

eFR$equal.pay.by.law <- FR$equal.pay.by.law
eFR$equal.pay.by.law.exp.01_1 <- FR$equal.pay.by.law.exp.01_1
eFR$equal.pay.by.law.exp.01_2 <- FR$equal.pay.by.law.exp.01_2
eFR$equal.pay.by.law.exp.se_1 <- FR$equal.pay.by.law.exp.se_1
eFR$equal.pay.by.law.exp.se_2 <- FR$equal.pay.by.law.exp.se_2
eFR$equal.pay.by.law.exp.le_1 <- FR$equal.pay.by.law.exp.le_1
eFR$equal.pay.by.law.exp.le_2 <- FR$equal.pay.by.law.exp.le_2
eFR$equal.pay.by.law.exp.ri_1 <- FR$equal.pay.by.law.exp.ri_1
eFR$equal.pay.by.law.exp.ri_2 <- FR$equal.pay.by.law.exp.ri_2
eFR$equal.pay.by.law.exp.dk_1 <- FR$equal.pay.by.law.exp.dk_1
eFR$equal.pay.by.law.exp.dk_2 <- FR$equal.pay.by.law.exp.dk_2

eFR$homoco.may.adopt <- FR$homoco.may.adopt
eFR$homoco.may.adopt.exp.01_1 <- FR$homoco.may.adopt.exp.01_1
eFR$homoco.may.adopt.exp.01_2 <- FR$homoco.may.adopt.exp.01_2
eFR$homoco.may.adopt.exp.se_1 <- FR$homoco.may.adopt.exp.se_1
eFR$homoco.may.adopt.exp.se_2 <- FR$homoco.may.adopt.exp.se_2
eFR$homoco.may.adopt.exp.le_1 <- FR$homoco.may.adopt.exp.le_1
eFR$homoco.may.adopt.exp.le_2 <- FR$homoco.may.adopt.exp.le_2
eFR$homoco.may.adopt.exp.ri_1 <- FR$homoco.may.adopt.exp.ri_1
eFR$homoco.may.adopt.exp.ri_2 <- FR$homoco.may.adopt.exp.ri_2
eFR$homoco.may.adopt.exp.dk_1 <- FR$homoco.may.adopt.exp.dk_1
eFR$homoco.may.adopt.exp.dk_2 <- FR$homoco.may.adopt.exp.dk_2

eFR$prof.exp.Tur_1<- FR$prof.exp.Tur.1st
eFR$prof.exp.Tur_2<- FR$prof.exp.Tur.2nd
eFR$prof.exp.NoMig_1<- FR$prof.exp.NoMig.1st
eFR$prof.exp.NoMig_2<- FR$prof.exp.NoMig.2nd
eFR$prof.exp.Mu_1 <- FR$prof.exp.Mu.1st
eFR$prof.exp.Chr_1 <- FR$prof.exp.Chr.1st
eFR$prof.exp.No_1 <- FR$prof.exp.No.1st
eFR$prof.exp.Mu_2 <- FR$prof.exp.Mu.2nd
eFR$prof.exp.Chr_2 <- FR$prof.exp.Chr.2nd
eFR$prof.exp.No_2 <- FR$prof.exp.No.2nd

#DE
eDE <- as_tibble(DE$INTNR) 
names(eDE) <- "INTNR"
eDE$cntry <- DE$cntry

eDE$MigBckGrnd <- DE$catraceDEb
eDE$binidrel2 <- DE$binidrel2
eDE$relMus <- DE$relMus
eDE$relChr <- DE$relChr
eDE$relOth <- DE$relOth
eDE$relNon <- DE$relNon

eDE$Female <- DE$Female
eDE$Education <- DE$Education 
eDE$Age <- DE$Age
eDE$AGE2 <- DE$AGE2
eDE$w8 <- DE$w8

#PTV
eDE$rad.ri <- DE$rad.ri
eDE$cen.ri <- DE$cen.ri
eDE$center <- DE$center
eDE$cen.le <- DE$cen.le 
eDE$rad.le <- DE$rad.le 

#different or same
eDE$Diff.Nat <- DE$Diff.Nat
eDE$Diff.Tur <- DE$Diff.Tur
eDE$Diff.Muslims <- DE$Diff.Muslims
eDE$Diff.Christians <- DE$Diff.Christians
eDE$Diff.Nonrelig <- DE$Diff.Nonrelig

eDE$equal.pay.by.law <- DE$equal.pay.by.law
eDE$equal.pay.by.law.exp.01_1 <- DE$equal.pay.by.law.exp.01_1
eDE$equal.pay.by.law.exp.01_2 <- DE$equal.pay.by.law.exp.01_2
eDE$equal.pay.by.law.exp.se_1 <- DE$equal.pay.by.law.exp.se_1
eDE$equal.pay.by.law.exp.se_2 <- DE$equal.pay.by.law.exp.se_2
eDE$equal.pay.by.law.exp.le_1 <- DE$equal.pay.by.law.exp.le_1
eDE$equal.pay.by.law.exp.le_2 <- DE$equal.pay.by.law.exp.le_2
eDE$equal.pay.by.law.exp.ri_1 <- DE$equal.pay.by.law.exp.ri_1
eDE$equal.pay.by.law.exp.ri_2 <- DE$equal.pay.by.law.exp.ri_2
eDE$equal.pay.by.law.exp.dk_1 <- DE$equal.pay.by.law.exp.dk_1
eDE$equal.pay.by.law.exp.dk_2 <- DE$equal.pay.by.law.exp.dk_2

eDE$homoco.may.adopt <- DE$homoco.may.adopt
eDE$homoco.may.adopt.exp.01_1 <- DE$homoco.may.adopt.exp.01_1
eDE$homoco.may.adopt.exp.01_2 <- DE$homoco.may.adopt.exp.01_2
eDE$homoco.may.adopt.exp.se_1 <- DE$homoco.may.adopt.exp.se_1
eDE$homoco.may.adopt.exp.se_2 <- DE$homoco.may.adopt.exp.se_2
eDE$homoco.may.adopt.exp.le_1 <- DE$homoco.may.adopt.exp.le_1
eDE$homoco.may.adopt.exp.le_2 <- DE$homoco.may.adopt.exp.le_2
eDE$homoco.may.adopt.exp.ri_1 <- DE$homoco.may.adopt.exp.ri_1
eDE$homoco.may.adopt.exp.ri_2 <- DE$homoco.may.adopt.exp.ri_2
eDE$homoco.may.adopt.exp.dk_1 <- DE$homoco.may.adopt.exp.dk_1
eDE$homoco.may.adopt.exp.dk_2 <- DE$homoco.may.adopt.exp.dk_2

eDE$prof.exp.Tur_1<- DE$prof.exp.Tur.1st
eDE$prof.exp.Tur_2<- DE$prof.exp.Tur.2nd
eDE$prof.exp.NoMig_1<- DE$prof.exp.NoMig.1st
eDE$prof.exp.NoMig_2<- DE$prof.exp.NoMig.2nd
eDE$prof.exp.Mu_1 <- DE$prof.exp.Mu.1st
eDE$prof.exp.Chr_1 <- DE$prof.exp.Chr.1st
eDE$prof.exp.No_1 <- DE$prof.exp.No.1st
eDE$prof.exp.Mu_2 <- DE$prof.exp.Mu.2nd
eDE$prof.exp.Chr_2 <- DE$prof.exp.Chr.2nd
eDE$prof.exp.No_2 <- DE$prof.exp.No.2nd

#NL
eNL <- as_tibble(NL$INTNR) 
names(eNL) <- "INTNR"
eNL$cntry <- NL$cntry

eNL$MigBckGrnd <- NL$catraceNLb
eNL$binidrel2 <- NL$binidrel2
eNL$relMus <- NL$relMus
eNL$relChr <- NL$relChr
eNL$relOth <- NL$relOth
eNL$relNon <- NL$relNon

eNL$Female <- NL$Female
eNL$Education <- NL$Education 
eNL$Age <- NL$Age
eNL$AGE2 <- NL$AGE2
eNL$w8 <- NL$w8

#PTV
eNL$rad.ri <- NL$rad.ri
eNL$cen.ri <- NL$cen.ri
eNL$center <- NL$center
eNL$cen.le <- NL$cen.le 
eNL$rad.le <- NL$rad.le 

#different or same
eNL$Diff.Nat <- NL$Diff.Nat
eNL$Diff.Tur <- NL$Diff.Tur
eNL$Diff.Muslims <- NL$Diff.Muslims
eNL$Diff.Christians <- NL$Diff.Christians
eNL$Diff.Nonrelig <- NL$Diff.Nonrelig

eNL$equal.pay.by.law <- NL$equal.pay.by.law
eNL$equal.pay.by.law.exp.01_1 <- NL$equal.pay.by.law.exp.01_1
eNL$equal.pay.by.law.exp.01_2 <- NL$equal.pay.by.law.exp.01_2
eNL$equal.pay.by.law.exp.se_1 <- NL$equal.pay.by.law.exp.se_1
eNL$equal.pay.by.law.exp.se_2 <- NL$equal.pay.by.law.exp.se_2
eNL$equal.pay.by.law.exp.le_1 <- NL$equal.pay.by.law.exp.le_1
eNL$equal.pay.by.law.exp.le_2 <- NL$equal.pay.by.law.exp.le_2
eNL$equal.pay.by.law.exp.ri_1 <- NL$equal.pay.by.law.exp.ri_1
eNL$equal.pay.by.law.exp.ri_2 <- NL$equal.pay.by.law.exp.ri_2
eNL$equal.pay.by.law.exp.dk_1 <- NL$equal.pay.by.law.exp.dk_1
eNL$equal.pay.by.law.exp.dk_2 <- NL$equal.pay.by.law.exp.dk_2

eNL$homoco.may.adopt <- NL$homoco.may.adopt
eNL$homoco.may.adopt.exp.01_1 <- NL$homoco.may.adopt.exp.01_1
eNL$homoco.may.adopt.exp.01_2 <- NL$homoco.may.adopt.exp.01_2
eNL$homoco.may.adopt.exp.se_1 <- NL$homoco.may.adopt.exp.se_1
eNL$homoco.may.adopt.exp.se_2 <- NL$homoco.may.adopt.exp.se_2
eNL$homoco.may.adopt.exp.le_1 <- NL$homoco.may.adopt.exp.le_1
eNL$homoco.may.adopt.exp.le_2 <- NL$homoco.may.adopt.exp.le_2
eNL$homoco.may.adopt.exp.ri_1 <- NL$homoco.may.adopt.exp.ri_1
eNL$homoco.may.adopt.exp.ri_2 <- NL$homoco.may.adopt.exp.ri_2
eNL$homoco.may.adopt.exp.dk_1 <- NL$homoco.may.adopt.exp.dk_1
eNL$homoco.may.adopt.exp.dk_2 <- NL$homoco.may.adopt.exp.dk_2

eNL$prof.exp.Tur_1<- NL$prof.exp.Tur.1st
eNL$prof.exp.Tur_2<- NL$prof.exp.Tur.2nd
eNL$prof.exp.NoMig_1 <- NL$prof.exp.NoMig.1st
eNL$prof.exp.NoMig_2 <- NL$prof.exp.NoMig.2nd
eNL$prof.exp.Mu_1 <- NL$prof.exp.Mu.1st
eNL$prof.exp.Chr_1 <- NL$prof.exp.Chr.1st
eNL$prof.exp.No_1 <- NL$prof.exp.No.1st
eNL$prof.exp.Mu_2 <- NL$prof.exp.Mu.2nd
eNL$prof.exp.Chr_2 <- NL$prof.exp.Chr.2nd
eNL$prof.exp.No_2 <- NL$prof.exp.No.2nd

#merge
FGN <- rbind(eFR, eDE, eNL)

#pivot
#FGN <- zap_labels(FGN)
FGNl <- FGN %>%
  pivot_longer(
    c(-INTNR,
      -cntry,
      
      -MigBckGrnd,
      
      -binidrel2,
      -relMus,
      -relChr,
      -relOth,
      -relNon,
      
      -Female,
      -Education,
      -Age,
      -AGE2,
      -w8,
      
      -rad.ri,
      -cen.ri,
      -center,
      -cen.le, 
      -rad.le, 
    
      -Diff.Nat,
      -Diff.Tur,
      -Diff.Muslims,
      -Diff.Christians,
      -Diff.Nonrelig,
      
      -equal.pay.by.law,
      -homoco.may.adopt),
    names_to = c(".value", "profile"),
    names_sep = "_",
    values_drop_na = F)

#----------------------------------------#
#--- fig 1 Histogram statement homoco ---#
#----------------------------------------#
FGNl <- FGNl %>% mutate(homoco.may.adopt010 = case_when(homoco.may.adopt == 0 ~ 0,
                                                               homoco.may.adopt == 0.1 ~ 1,
                                                               homoco.may.adopt == 0.2 ~ 1,
                                                               homoco.may.adopt == 0.3 ~ 3,
                                                               homoco.may.adopt == 0.4 ~ 4,
                                                               homoco.may.adopt == 0.5 ~ 5,
                                                               homoco.may.adopt == 0.6 ~ 6,
                                                               homoco.may.adopt == 0.7 ~ 7,
                                                               homoco.may.adopt == 0.8 ~ 8,
                                                               homoco.may.adopt == 0.9 ~ 9,
                                                               homoco.may.adopt == 1 ~ 10)) 

Fig1 <- ggplot(FGNl, aes(x = factor(homoco.may.adopt010), 
                         weight = w8,
                         label = scales::percent(prop.table(stat(count))))) + 
  theme_minimal() +
  ylab(" ") + 
  xlab("Fully disagree                                                                                                                  Fully agree ") +
  geom_bar(aes(y = (..count..)/sum(..count..)), 
           fill = 'steelblue',
           position = "dodge") +
  labs(#subtitle = "Histogram",
    #caption = "This is the caption",
    title = "Figure 1.\nHistogram of responses to 'homosexual couples are allowed to adopt children'") + 
  scale_y_continuous(labels = scales::percent_format(accuracy = 1L)) + 
  theme(plot.title.position = "plot")
Fig1

#-----------------------------------------#
#--- fig 2a Marginal Means Stereotyping ---# Muslim
#-----------------------------------------#

#Marginal Means
#politician profile
#Stereo.atyping
FGNl <- FGNl %>% mutate(Politician.Religion = case_when(prof.exp.Mu == 1 ~ "Muslim politician",
                                                        #prof.exp.Chr == 1 ~ "Christian",
                                                        prof.exp.No == 1 ~ "non-religious politician")) 
FGNl$Politician.Religion <- as.factor(FGNl$Politician.Religion)

#marginal means
Stereo.a <- mm(FGNl, homoco.may.adopt.exp.01 ~ Politician.Religion,
             id = ~ INTNR, h0 = 0.5, weights = ~ w8)
Stereo.a

Stereo.aDF <- data.frame(
  names=c("Muslim", "non-religious"),
  estimate=Stereo.a$estimate*100,
  conf.low=Stereo.a$lower*100,
  conf.high=Stereo.a$upper*100,
  number=c("002", "001"))

Stereo.aDF

Fig2 <- ggplot(data = Stereo.aDF, 
               aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high),
                  color = c("#DC863B", "#899DA4"),
                  fill = c("#DC863B", "#899DA4")) +
  theme_minimal() +
  #ggtitle("Do citizens Stereo.atype Muslim politicians?") + 
  ylab("Politician's religion:\n\n") + 
  xlab("% that expects politician to be pro-same-sex adoption (marginal means)") + 
  xlim(0, 100) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
       #caption = "This is the caption",
       title = "Figure 2.\nDo voters stereotype Muslim politicians?") + 
  theme(plot.title.position = "plot")
Fig2

#-----------------------------------------#
#--- fig 2b Marginal Means Stereotyping ---# Turkish
#-----------------------------------------#

#Marginal Means
#politician profile
#Stereo.btyping
FGNl <- FGNl %>% mutate(Politician.MigBckgrnd = case_when(prof.exp.Tur == 1 ~ "Turkish politician",
                                                        #prof.exp.Chr == 1 ~ "Christian",
                                                        prof.exp.NoMig == 1 ~ "politician without migration background")) 
FGNl$Politician.MigBckgrnd <- as.factor(FGNl$Politician.MigBckgrnd)

#marginal means
Stereo.b <- mm(FGNl, homoco.may.adopt.exp.01 ~ Politician.MigBckgrnd,
             id = ~ INTNR, h0 = 0.5, weights = ~ w8)
Stereo.b

Stereo.bDF <- data.frame(
  names=c("Turkish", "None"),
  estimate=Stereo.b$estimate*100,
  conf.low=Stereo.b$lower*100,
  conf.high=Stereo.b$upper*100,
  number=c("002", "001"))

Stereo.bDF

Fig2b <- ggplot(data = Stereo.bDF, 
                aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high),
                  color = c("#DC863B", "#899DA4"),
                  fill = c("#DC863B", "#899DA4")) +
  theme_minimal() +
  #ggtitle("Do citizens Stereo.btype Turkish politicians?") + 
  ylab("Politician's migration background:\n\n") + 
  xlab("% that expects politician to be pro-LGB rights (marginal means)") + 
  xlim(0, 100) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Figure 2b.\nDo voters Stereotype Turkish politicians?") + 
  theme(plot.title.position = "plot")
Fig2b

#-----------------------------------------#
#--- fig 2c Marginal Means Stereotyping ---# Turkish Muslim
#-----------------------------------------#

FGNl$Stereo.c <- 
  interaction(FGNl$Politician.MigBckgrnd, FGNl$Politician.Religion, sep = "+")
Stereo.c <- mm(FGNl, homoco.may.adopt.exp.01 ~ Stereo.c,
                  id = ~ INTNR, h0 = 0.5, weights = ~ w8)
Stereo.c

#marginal means
Stereo.c <- mm(FGNl, homoco.may.adopt.exp.01 ~ Stereo.c,
             id = ~ INTNR, h0 = 0.5, weights = ~ w8)
Stereo.c

Stereo.cDF <- data.frame(
  names=c("Muslim without migration background", "Turkish Muslim", "non-religious without migration background", "non religious and Turkish"),
  estimate=Stereo.c$estimate*100,
  conf.low=Stereo.c$lower*100,
  conf.high=Stereo.c$upper*100,
  number=c("002", "004", "001", "003"))
Stereo.cDF

Fig2c <- ggplot(data = Stereo.cDF, 
                aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high),
                  color = c("#DC863B", "#899DA4", "#DC863B", "#899DA4"),
                  fill = c("#DC863B", "#899DA4","#DC863B", "#899DA4" )) +
  theme_minimal() +
  #ggtitle("Do citizens Stereo.ctype Turkish politicians?") + 
  ylab("Politician's religion and migration background:\n\n") + 
  xlab("% that expects politician to be pro-LGB rights (marginal means)") + 
  xlim(0, 101) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Figure 2c.\nDo voters Stereotype Muslim and/or Turkish politicians?") + 
  theme(plot.title.position = "plot")
Fig2c

#---------------------------------------#
#--- fig 3 Marginal Means Projection ---#
#---------------------------------------#

#projection
#symmetrical approach
FGNl <- FGNl %>% mutate(homoco.may.adopt.as.factor = case_when(homoco.may.adopt == 0 ~ "Anti",
                                                               homoco.may.adopt == 0.1 ~ "Middle",
                                                               homoco.may.adopt == 0.2 ~ "Middle",
                                                               homoco.may.adopt == 0.3 ~ "Middle",
                                                               homoco.may.adopt == 0.4 ~ "Middle",
                                                               homoco.may.adopt == 0.5 ~ "Middle",
                                                               homoco.may.adopt == 0.6 ~ "Middle",
                                                               homoco.may.adopt == 0.7 ~ "Middle",
                                                               homoco.may.adopt == 0.8 ~ "Middle",
                                                               homoco.may.adopt == 0.9 ~ "Middle",
                                                               homoco.may.adopt == 1 ~ "Pro"))
FGNl$homoco.may.adopt.as.factor <- as.factor(FGNl$homoco.may.adopt.as.factor)

Proj <- mm(FGNl, homoco.may.adopt.exp.01 ~ homoco.may.adopt.as.factor,
           id = ~ INTNR, h0 = 0.5, weights = ~ w8)
Proj

ProjDF <- data.frame(
  names=c("Anti", "Middle", "Pro"),
  estimate=Proj$estimate*100,
  conf.low=Proj$lower*100,
  conf.high=Proj$upper*100,
  number=c("003", "002", "001"))

ProjDF

Fig3 <- ggplot(data = ProjDF, 
               aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high),
                  color = c("#5BBCD6", "#F98400", "#00A08A"),
                  fill = c("#5BBCD6", "#F98400", "#00A08A")) +
  theme_minimal() +
  #ggtitle("Do citizens Projtype Muslim politicians?") + 
  ylab("Views on same-sex adoption:\n\n") + 
  xlab("% that expects politician to be same-sex adoption (marginal means)") + 
  xlim(0, 100) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
       #caption = "This is the caption",
       title = "Figure 3.\nDo voters project their views onto politicians?") + 
  theme(plot.title.position = "plot")
Fig3

#-----------------------------------------#
#--- fig 4a Projection AND Stereotyping ---#
#-----------------------------------------#

#Stereotyping AND Projection
FGNl$Stereo.Proj.a <- 
  interaction(FGNl$Politician.Religion, FGNl$homoco.may.adopt.as.factor, sep = "+")
Stereo.Proj.a <- mm(FGNl, homoco.may.adopt.exp.01 ~ Stereo.Proj.a,
                  id = ~ INTNR, h0 = 0.5, weights = ~ w8)
Stereo.Proj.a

StereoProj.aDF <- data.frame(
  names=c("Anti + Muslim", "Anti + non-religious", 
          "Middle + Muslim", "Middle + non-religious",
          "Pro + Muslim", "Pro + non-religious"),
  estimate=Stereo.Proj.a$estimate*100,
  conf.low=Stereo.Proj.a$lower*100,
  conf.high=Stereo.Proj.a$upper*100,
  number=c("006", "005", "004", "003", "002", "001"))

StereoProj.aDF

hline.fig4 <- data.frame(z = c(2.5,
                               4.5)) 

Fig4a <- ggplot(data = StereoProj.aDF, 
                aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high),
                  color = c("#DC863B", "#899DA4", "#DC863B", "#899DA4", "#DC863B", "#899DA4"),
                  fill = c("#DC863B", "#899DA4", "#DC863B", "#899DA4", "#DC863B", "#899DA4")) +
  theme_minimal() +
  #ggtitle("Do citizens StereoProj.atype Muslim politicians?") + 
  ylab("Views on same-sex adoption:\n+\nPolitician's religion:\n\n") + 
  xlab("% that expects politician to be pro-same-sex adoption (marginal means)") + 
  xlim(-10, 100) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Figure 4.\nDo voters stereotype or project?") + 
  theme(plot.title.position = "plot") +
  geom_hline(linetype = "dotted", 
             aes(yintercept = z), 
             hline.fig4)
Fig4a

#--------------------------#
#--- Perceived distance ---#
#--------------------------#

#Diff.Muslims
Proj.Diff.Muslims <- mm(FGNl, Diff.Muslims ~ homoco.may.adopt.as.factor,
                  id = ~ INTNR, h0 = 0.5, weights = ~ w8)
Proj.Diff.Muslims

#diference Muslims
FGN.Pro <- subset(FGNl, homoco.may.adopt.as.factor=="Pro")
Fig5.Muslim.Pro <- ggplot(FGN.Pro, aes(x = factor(Diff.Muslims), 
                         weight = w8,
                         label = scales::percent(prop.table(stat(count))))) + 
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") +
  geom_bar(aes(y = (..count..)/sum(..count..)), 
           fill = 'steelblue',
           position = "dodge") +
  scale_y_continuous(limits = c(0,.7), labels = scales::percent_format(accuracy = 1L)) + 
  theme(plot.title.position = "plot")
#Fig5.Muslim.Pro

FGN.Middle <- subset(FGNl, homoco.may.adopt.as.factor=="Middle")
Fig5.Muslim.Middle <- ggplot(FGN.Middle, aes(x = factor(Diff.Muslims), 
                                       weight = w8,
                                       label = scales::percent(prop.table(stat(count))))) + 
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") +
  geom_bar(aes(y = (..count..)/sum(..count..)), 
           fill = 'steelblue',
           position = "dodge") +
  scale_y_continuous(limits = c(0,.7), labels = scales::percent_format(accuracy = 1L)) + 
  theme(plot.title.position = "plot")
#Fig5.Muslim.Middle

FGN.Anti <- subset(FGNl, homoco.may.adopt.as.factor=="Anti")
Fig5.Muslim.Anti <- ggplot(FGN.Anti, aes(x = factor(Diff.Muslims), 
                                             weight = w8,
                                             label = scales::percent(prop.table(stat(count))))) + 
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") +
  geom_bar(aes(y = (..count..)/sum(..count..)), 
           fill = 'steelblue',
           position = "dodge") +
  scale_y_continuous(limits = c(0,.7), labels = scales::percent_format(accuracy = 1L)) + 
  theme(plot.title.position = "plot")
#Fig5.Muslim.Anti

#difference non reliigous
Fig5.nonrelig.Pro <- ggplot(FGN.Pro, aes(x = factor(Diff.Nonrelig), 
                                       weight = w8,
                                       label = scales::percent(prop.table(stat(count))))) + 
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") +
  geom_bar(aes(y = (..count..)/sum(..count..)), 
           fill = 'steelblue',
           position = "dodge") +
  labs(#subtitle = "Histogram",
    #caption = "This is the caption",
    title = "Histogram of perceived similarity with people who do not practice any religion amongst:\n\nPro-flankers") + 
  scale_y_continuous(limits = c(0,.7), labels = scales::percent_format(accuracy = 1L)) + 
  theme(plot.title.position = "plot")
#Fig5.nonrelig.Pro

Fig5.nonrelig.Middle <- ggplot(FGN.Middle, aes(x = factor(Diff.Nonrelig), 
                                             weight = w8,
                                             label = scales::percent(prop.table(stat(count))))) + 
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") +
  geom_bar(aes(y = (..count..)/sum(..count..)), 
           fill = 'steelblue',
           position = "dodge") +
  labs(#subtitle = "Histogram",
    #caption = "This is the caption",
    title = "Moderates") + 
  scale_y_continuous(limits = c(0,.7), labels = scales::percent_format(accuracy = 1L)) + 
  theme(plot.title.position = "plot")
#Fig5.nonrelig.Middle

Fig5.nonrelig.Anti <- ggplot(FGN.Anti, aes(x = factor(Diff.Nonrelig), 
                                         weight = w8,
                                         label = scales::percent(prop.table(stat(count))))) + 
  theme_minimal() +
  ylab(" ") + 
  xlab(" ") +
  geom_bar(aes(y = (..count..)/sum(..count..)), 
           fill = 'steelblue',
           position = "dodge") +
  labs(#subtitle = "Histogram",
    #caption = "This is the caption",
    title = "Anti-flankers") + 
  scale_y_continuous(limits = c(0,.7), labels = scales::percent_format(accuracy = 1L)) + 
  theme(plot.title.position = "plot")
#Fig5.nonrelig.Anti

#marginal means
ProjDF.Diff.Muslims <- data.frame(
  names=c("Anti-flanker", "Moderate", "Pro-flanker"),
  estimate=Proj.Diff.Muslims$estimate,
  conf.low=Proj.Diff.Muslims$lower,
  conf.high=Proj.Diff.Muslims$upper,
  number=c("003", "002", "001"))

ProjDF.Diff.Muslims

Fig5.Diff.Muslims <- ggplot(data = ProjDF.Diff.Muslims, 
                      aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high),
                  color = c("#5BBCD6", "#F98400", "#00A08A"),
                  fill = c("#5BBCD6", "#F98400", "#00A08A")) +
  theme_minimal() +
  #ggtitle("Do citizens Projtype Muslim politicians?") + 
  ylab("  ") + 
  xlab(" ") + 
  xlim(1.6, 4.41) +
  geom_vline(xintercept = 5) + 
  theme(plot.title.position = "plot")
#Fig5.Diff.Muslims

#Diff.Christians
Proj.Diff.Christians <- mm(FGNl, Diff.Christians ~ homoco.may.adopt.as.factor,
                  id = ~ INTNR, h0 = 0.5, weights = ~ w8)
Proj.Diff.Christians

ProjDF.Diff.Christians <- data.frame(
  names=c("Anti-flanker", "Moderate", "Pro-flanker"),
  estimate=Proj.Diff.Christians$estimate,
  conf.low=Proj.Diff.Christians$lower,
  conf.high=Proj.Diff.Christians$upper,
  number=c("003", "002", "001"))

ProjDF.Diff.Christians

Fig5.Diff.Christians <- ggplot(data = ProjDF.Diff.Christians, 
                      aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high),
                  color = c("#5BBCD6", "#F98400", "#00A08A"),
                  fill = c("#5BBCD6", "#F98400", "#00A08A")) +
  theme_minimal() +
  #ggtitle("Do citizens Projtype Muslim politicians?") + 
  ylab("  ") + 
  xlab(" ") + 
  xlim(1.6, 4.41) +
  geom_vline(xintercept = 5) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "people who practice Christianity?") + 
  theme(plot.title.position = "plot")
#Fig5.Diff.Christians

#Diff.Nonrelig
Proj.Diff.Nonrelig <- mm(FGNl, Diff.Nonrelig ~ homoco.may.adopt.as.factor,
                  id = ~ INTNR, h0 = 0.5, weights = ~ w8)
Proj.Diff.Nonrelig

ProjDF.Diff.Nonrelig <- data.frame(
  names=c("Anti-flanker", "Moderate", "Pro-flanker"),
  estimate=Proj.Diff.Nonrelig$estimate,
  conf.low=Proj.Diff.Nonrelig$lower,
  conf.high=Proj.Diff.Nonrelig$upper,
  number=c("003", "002", "001"))

ProjDF.Diff.Nonrelig

Fig5.Diff.Nonrelig <- ggplot(data = ProjDF.Diff.Nonrelig, 
                      aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high),
                  color = c("#5BBCD6", "#F98400", "#00A08A"),
                  fill = c("#5BBCD6", "#F98400", "#00A08A")) +
  theme_minimal() +
  #ggtitle("Do citizens Projtype Muslim politicians?") + 
  ylab("  ") + 
  xlab(" ") + 
  xlim(0, 10) +
  geom_vline(xintercept = 5) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "people who do not practice any religion?") + 
  theme(plot.title.position = "plot")
#Fig5.Diff.Nonrelig

Diff.Mus <- Fig5.Muslim.Pro/
  Fig5.Muslim.Middle/
  Fig5.Muslim.Anti
#Diff.Mus

Diff.nonrelig <- Fig5.nonrelig.Pro/
  Fig5.nonrelig.Middle/
  Fig5.nonrelig.Anti
#Diff.nonrelig

fig5 <- Fig5.Diff.Muslims+Diff.Mus + #/ Fig5.Diff.Nonrelig+Diff.nonrelig
  plot_annotation(title = 'Figure 5.\nDo flankers and moderates perceive being similar to people who practice Islam?',
                  caption = 'Perceived similarity: 0 = Completely different, 10 = Completely the same') #+
fig5 

#--------------------------#
#--- mediation analysis ---#
#--------------------------#

#anti
FGN.Muslim.Anti <- subset(FGNl, homoco.may.adopt.as.factor=="Anti" & Politician.Religion=="Muslim politician")
FGN.Muslim.Anti.lm <- miceadds::lm.cluster(
  data=FGN.Muslim.Anti, 
  formula = FGN.Muslim.Anti$homoco.may.adopt.exp.01 ~ 
    FGN.Muslim.Anti$Diff.Nat +
    FGN.Muslim.Anti$Diff.Tur +
    FGN.Muslim.Anti$Diff.Christians +
    FGN.Muslim.Anti$Diff.Nonrelig +
    FGN.Muslim.Anti$Diff.Muslims,
  cluster=FGN.Muslim.Anti$INTNR, weights = FGN.Muslim.Anti$w8)

#Middle
FGN.Muslim.Middle <- subset(FGNl, homoco.may.adopt.as.factor=="Middle" & Politician.Religion=="Muslim politician")
FGN.Muslim.Middle.lm <- miceadds::lm.cluster(
  data=FGN.Muslim.Middle, 
  formula = FGN.Muslim.Middle$homoco.may.adopt.exp.01 ~ 
    FGN.Muslim.Middle$Diff.Nat +
    FGN.Muslim.Middle$Diff.Tur +
    FGN.Muslim.Middle$Diff.Christians +
    FGN.Muslim.Middle$Diff.Nonrelig +
    FGN.Muslim.Middle$Diff.Muslims,
  cluster=FGN.Muslim.Middle$INTNR, weights = FGN.Muslim.Middle$w8)

#Pro
FGN.Muslim.Pro <- subset(FGNl, homoco.may.adopt.as.factor=="Pro" & Politician.Religion=="Muslim politician")
FGN.Muslim.Pro.lm <- miceadds::lm.cluster(
  data=FGN.Muslim.Pro, 
  formula = FGN.Muslim.Pro$homoco.may.adopt.exp.01 ~ 
    FGN.Muslim.Pro$Diff.Nat +
    FGN.Muslim.Pro$Diff.Tur +
    FGN.Muslim.Pro$Diff.Christians +
    FGN.Muslim.Pro$Diff.Nonrelig +
    FGN.Muslim.Pro$Diff.Muslims,
  cluster=FGN.Muslim.Pro$INTNR, weights = FGN.Muslim.Pro$w8)

FGN.Muslim.Anti.tib <- as_tibble(summary(FGN.Muslim.Anti.lm))
FGN.Muslim.Middle.tib <- as_tibble(summary(FGN.Muslim.Middle.lm))
FGN.Muslim.Pro.tib <- as_tibble(summary(FGN.Muslim.Pro.lm))

FGN.Muslim.Anti.tib <- FGN.Muslim.Anti.tib[-1, ] #remove the intercept
FGN.Muslim.Anti.tib <- FGN.Muslim.Anti.tib[-1, ] #remove 
FGN.Muslim.Anti.tib <- FGN.Muslim.Anti.tib[-1, ] #remove 
FGN.Muslim.Anti.tib <- FGN.Muslim.Anti.tib[-1, ] #remove 
FGN.Muslim.Anti.tib <- FGN.Muslim.Anti.tib[-1, ] #remove 

FGN.Muslim.Middle.tib <- FGN.Muslim.Middle.tib[-1, ] #remove the intercept
FGN.Muslim.Middle.tib <- FGN.Muslim.Middle.tib[-1, ] #remove 
FGN.Muslim.Middle.tib <- FGN.Muslim.Middle.tib[-1, ] #remove 
FGN.Muslim.Middle.tib <- FGN.Muslim.Middle.tib[-1, ] #remove 
FGN.Muslim.Middle.tib <- FGN.Muslim.Middle.tib[-1, ] #remove 

FGN.Muslim.Pro.tib <- FGN.Muslim.Pro.tib[-1, ] #remove the intercept
FGN.Muslim.Pro.tib <- FGN.Muslim.Pro.tib[-1, ] #remove 
FGN.Muslim.Pro.tib <- FGN.Muslim.Pro.tib[-1, ] #remove 
FGN.Muslim.Pro.tib <- FGN.Muslim.Pro.tib[-1, ] #remove 
FGN.Muslim.Pro.tib <- FGN.Muslim.Pro.tib[-1, ] #remove 

FGN.Pro.Mod.Ant <- rbind(FGN.Muslim.Pro.tib,FGN.Muslim.Middle.tib,FGN.Muslim.Anti.tib)

FGN.Pro.Mod.Ant.df <- data.frame(
  names=c("Pro-flanker", "Moderate", "Anti-flanker"),
  estimate=FGN.Pro.Mod.Ant$Estimate,
  conf.low=((FGN.Pro.Mod.Ant$Estimate)-1.96*FGN.Pro.Mod.Ant$`Std. Error`),
  conf.high=((FGN.Pro.Mod.Ant$Estimate)+1.96*FGN.Pro.Mod.Ant$`Std. Error`),
  number=c("001", "002", "003"))

#visuals
Fig6.Muslim.Pro.Mod.Ant <- ggplot(data = FGN.Pro.Mod.Ant.df, 
                             aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high),
                  color = c("#5BBCD6", "#F98400", "#00A08A"),
                  fill = c("#5BBCD6", "#F98400", "#00A08A")) +
  theme_minimal() +
  #ggtitle("Do citizens Projtype Muslim politicians?") + 
  ylab("  ") + 
  xlab(" ") + 
  xlim(-.15, .15) +
  geom_vline(xintercept = 0) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = " ") + 
  theme(plot.title.position = "plot")
#Fig6.Muslim.Pro.Mod.Ant

fig6 <- Fig6.Muslim.Pro.Mod.Ant +
  plot_annotation(title = 'Figure 6.\nDoes perceived similarity with people who practice Islam predict what voters\nexpect of Muslim politicians towards same-sex adoption?',
                  #subtitle = 'Overall, they do, but there are some exceptions',
                  caption = "Figure 6. 
                  Linear models, due to repeated measures I cluster at the level of the respondent. The dependent variable is whether 
                  voters expect a Muslim politician to be in favor of same-sex adoption, subsetted by whether the voter is a pro-flanker, 
                  moderate or anti-flanker. The independent variables are 'How similar do you consider yourself to be from 1) people who 
                  practice Islam, 2) people who practice Christianity, 3) people who do not practice any religion, 4) French/German/Dutch 
                  people without a migration background or 5) French/German/Dutch people with a Turkish background. I coded 0 as 
                  completely different and 10 as completely the same. I apply weights for migration background, sex, education, region 
                  and urbanization. Errorbars indicate the 95% confidence interval.") #+
fig6 

#-----------------------------------------#
#--- fig 4b Projection AND Stereotyping ---#
#-----------------------------------------#

#Stereotyping AND Projection
FGNl$Stereo.Proj.b <- 
  interaction(FGNl$Politician.MigBckgrnd, FGNl$homoco.may.adopt.as.factor, sep = "+")
Stereo.Proj.b <- mm(FGNl, homoco.may.adopt.exp.01 ~ Stereo.Proj.b,
                  id = ~ INTNR, h0 = 0.5, weights = ~ w8)
Stereo.Proj.b

StereoProj.bDF <- data.frame(
  names=c("Anti + no migration background", "Anti + Turkish", 
          "Middle + no migration background", "Middle + Turkish",
          "Pro + no migration background", "Pro + Turkish"),
  estimate=Stereo.Proj.b$estimate*100,
  conf.low=Stereo.Proj.b$lower*100,
  conf.high=Stereo.Proj.b$upper*100,
  number=c("006", "005", "004", "003", "002", "001"))

StereoProj.bDF

hline.fig4 <- data.frame(z = c(2.5,
                               4.5)) 

Fig4b <- ggplot(data = StereoProj.bDF, 
                aes(x = estimate, y = reorder(names,desc(-estimate)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high),
                  color = c("#DC863B", "#899DA4", "#DC863B", "#899DA4", "#DC863B", "#899DA4"),
                  fill = c("#DC863B", "#899DA4", "#DC863B", "#899DA4", "#DC863B", "#899DA4")) +
  theme_minimal() +
  #ggtitle("Do citizens StereoProj.btype Turkish politicians?") + 
  ylab("Views on LGB rights:\n+\nPolitician's migration background:\n\n") + 
  xlab("% that expects politician to be pro-LGB rights (marginal means)") + 
  xlim(-10, 100) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Figure 4.\nDo voters stereotype or Project?") + 
  theme(plot.title.position = "plot") +
  geom_hline(linetype = "dotted", 
             aes(yintercept = z), 
             hline.fig4)
Fig4b

#-----------------------------------------#
#--- fig 4c Projection AND Stereotyping ---#
#-----------------------------------------#

#Stereotyping AND Projection
FGNl$Stereo.Proj.c <- 
  interaction(FGNl$Politician.MigBckgrnd, FGNl$Politician.Religion, FGNl$homoco.may.adopt.as.factor, sep = "+")
Stereo.Proj.c <- mm(FGNl, homoco.may.adopt.exp.01 ~ Stereo.Proj.c,
                    id = ~ INTNR, h0 = 0.5, weights = ~ w8)
Stereo.Proj.c

StereoProj.cDF <- data.frame(
  names=c("Anti + no migration background + Muslim", "Anti + Turkish + Muslim", "Anti + no migration background + non-religious", "Anti + Turkish + non-religious", 
          "Middle + no migration background + Muslim", "Middle + Turkish + Muslim", "Middle + no migration background + non-religious", "Middle + Turkish + non-religious",
          "Pro + no migration background + Muslim", "Pro + Turkish + Muslim", "Pro + no migration background + non-religious", "Pro + Turkish + non-religious"),
  estimate=Stereo.Proj.c$estimate*100,
  conf.low=Stereo.Proj.c$lower*100,
  conf.high=Stereo.Proj.c$upper*100,
  number=c("009", "010", "011", "012", "005", "006", "007", "009", "001", "002", "003", "004"))

StereoProj.cDF

hline.fig4 <- data.frame(z = c(4.5,
                               8.5)) 

Fig4c <- ggplot(data = StereoProj.cDF, 
                aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high),
                  color = c("#DC863B", "#899DA4", "#DC863B", "#899DA4", "#DC863B", "#899DA4","#DC863B", "#899DA4", "#DC863B", "#899DA4", "#DC863B", "#899DA4"),
                  fill = c("#DC863B", "#899DA4", "#DC863B", "#899DA4", "#DC863B", "#899DA4","#DC863B", "#899DA4", "#DC863B", "#899DA4", "#DC863B", "#899DA4")) +
  theme_minimal() +
  #ggtitle("Do citizens StereoProj.ctype Turkish politicians?") + 
  ylab("Views on LGB rights:\n+\nPolitician's migration background:\n\n") + 
  xlab("% that expects politician to be pro-LGB rights (marginal means)") + 
  xlim(-23, 123) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Figure 4.\nDo voters stereotype or Project?") + 
  theme(plot.title.position = "plot") +
  geom_hline(linetype = "dotted", 
             aes(yintercept = z), 
             hline.fig4)
Fig4c

#----------------#
#--- Appendix ---#
#----------------#

#-----------------------------#
#--- Fig1 with percentages ---#
#-----------------------------#

Fig1.Appendix <- ggplot(FGNl, aes(x = factor(homoco.may.adopt010), 
                         weight = w8,
                         label = scales::percent(prop.table(stat(count))))) + 
  theme_minimal() +
  ylab(" ") + 
  xlab("Fully disagree                                                                                                                  Fully agree ") +
  geom_bar(aes(y = (..count..)/sum(..count..)), 
           fill = 'steelblue',
           position = "dodge") +
  labs(#subtitle = "Histogram",
    #caption = "This is the caption",
    title = "Figure 1.\nHistogram of responses to 'homosexual couples are allowed to adopt children'") + 
  scale_y_continuous(labels = scales::percent_format(accuracy = 1L)) + 
  theme(plot.title.position = "plot") + 
  geom_text(aes(y = ((..count..)/sum(..count..)), label = scales::percent((..count..)/sum(..count..))), stat = "count", vjust = -0.25) 
Fig1.Appendix

#----------------------------#
#--- Tables figures 2,3,4 ---#
#----------------------------#

StereoDF.tab <- StereoDF %>% gt() %>%
  tab_header(title = md("**Table of Figure 2:**\n Do voters stereotype Muslim politicians?")) %>%
  cols_align(align = "left") %>%
  tab_options(heading.align = "left") %>%
  tab_source_note(source_note = "Data frame that formed the input for Figure 2. Names represent the religion of the politician (Muslim, non-religious). Estimate represents % that expects politician to be pro-LGB rights (marginal means). Confidence intervals are 95%. The number indicates the position in the plot.") %>% 
  fmt_number(
    columns = 2:4,
    decimals = 2)
StereoDF.tab

ProjDF.tab <- ProjDF %>% gt() %>%
  tab_header(title = md("**Table of Figure 3:**\n Do voters project their views onto politicians?")) %>%
  cols_align(align = "left") %>%
  tab_options(heading.align = "left") %>%
  tab_source_note(source_note = "Data frame that formed the input for Figure 3. Names represent the own position of the voter (Anti, Middle, Pro). Estimate represents % that expects politician to be pro-LGB rights (marginal means). Confidence intervals are 95%. The number indicates the position in the plot.") %>% 
  fmt_number(
    columns = 2:4,
    decimals = 2)
ProjDF.tab

StereoProjDF.tab <- StereoProjDF %>% gt() %>%
  tab_header(title = md("**Table of Figure 4:**\n Do voters stereotype or project?")) %>%
  cols_align(align = "left") %>%
  tab_options(heading.align = "left") %>%
  tab_source_note(source_note = "Data frame that formed the input for Figure 4. Names represent the own position of the voter (Anti, Middle, Pro) and the religion of the politician (Muslim, non-religious). Estimate represents % that expects politician to be pro-LGB rights (marginal means). Confidence intervals are 95%. The number indicates the position in the plot.") %>% 
  fmt_number(
    columns = 2:4,
    decimals = 2)
StereoProjDF.tab

#------------------------------------------#
#--- Appendix2 What if they don't know? ---#
#------------------------------------------#

#------------------------------------------#
#--- fig A1 Marginal Means Stereotyping ---#
#------------------------------------------#

Stereo.Appendix2 <- mm(FGNl, homoco.may.adopt.exp.dk ~ Politician.Religion,
             id = ~ INTNR, h0 = 0.5, weights = ~ w8)
Stereo.Appendix2

Stereo.Appendix2DF <- data.frame(
  names=c("Muslim", "non-religious"),
  estimate=Stereo.Appendix2$estimate*100,
  conf.low=Stereo.Appendix2$lower*100,
  conf.high=Stereo.Appendix2$upper*100,
  number=c("002", "001"))

Fig.Appendix2.1 <- ggplot(data = Stereo.Appendix2DF, 
               aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high),
                  color = c("#DC863B", "#899DA4"),
                  fill = c("#DC863B", "#899DA4")) +
  theme_minimal() +
  #ggtitle("Do citizens Stereo.Appendix2type Muslim politicians?") + 
  ylab("Politician's religion:\n\n") + 
  xlab("% that answered 'don't know' (marginal means)") + 
  xlim(0, 100) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "How often do voters answer don't know?") + 
  theme(plot.title.position = "plot")
Fig.Appendix2.1

Stereo.Appendix2DF.tab <- Stereo.Appendix2DF %>% gt() %>%
  tab_header(title = md(" ")) %>%
  cols_align(align = "left") %>%
  tab_options(heading.align = "left") %>%
  tab_source_note(source_note = "") %>% 
  fmt_number(
    columns = 2:4,
    decimals = 2)
Stereo.Appendix2DF.tab

#---------------------------------------#
#--- fig 3 Marginal Means Projection ---#
#---------------------------------------#

Proj.Appendix2 <- mm(FGNl, homoco.may.adopt.exp.dk ~ homoco.may.adopt.as.factor,
           id = ~ INTNR, h0 = 0.5, weights = ~ w8)
Proj.Appendix2

Proj.Appendix2DF <- data.frame(
  names=c("Anti", "Middle", "Pro"),
  estimate=Proj.Appendix2$estimate*100,
  conf.low=Proj.Appendix2$lower*100,
  conf.high=Proj.Appendix2$upper*100,
  number=c("003", "002", "001"))

Proj.Appendix2DF

Fig.Appendix2.2 <- ggplot(data = Proj.Appendix2DF, 
               aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high),
                  color = c("#5BBCD6", "#F98400", "#00A08A"),
                  fill = c("#5BBCD6", "#F98400", "#00A08A")) +
  theme_minimal() +
  #ggtitle("Do citizens Proj.Appendix2type Muslim politicians?") + 
  ylab("Views on LGB rights:\n\n") + 
  xlab("% that answered 'don't know' (marginal means)") + 
  xlim(0, 100) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Who answered 'don't know'?") + 
  theme(plot.title.position = "plot")
Fig.Appendix2.2

Proj.Appendix2DF.tab <- Proj.Appendix2DF %>% gt() %>%
  tab_header(title = md(" ")) %>%
  cols_align(align = "left") %>%
  tab_options(heading.align = "left") %>%
  tab_source_note(source_note = "") %>% 
  fmt_number(
    columns = 2:4,
    decimals = 2)
Proj.Appendix2DF.tab

#-----------------------------------------#
#--- fig 4 Projection AND Stereotyping ---#
#-----------------------------------------#

#Stereotyping AND Proj.Appendix2ection
FGNl$Stereo.Proj.Appendix2 <- 
  interaction(FGNl$Politician.Religion, FGNl$homoco.may.adopt.as.factor, sep = "+")
Stereo.Proj.Appendix2 <- mm(FGNl, homoco.may.adopt.exp.dk ~ Stereo.Proj.Appendix2,
                  id = ~ INTNR, h0 = 0.5, weights = ~ w8)
Stereo.Proj.Appendix2


StereoProj.Appendix2DF <- data.frame(
  names=c("Anti + Muslim", "Anti + non-religious", 
          "Middle + Muslim", "Middle + non-religious",
          "Pro + Muslim", "Pro + non-religious"),
  estimate=Stereo.Proj.Appendix2$estimate*100,
  conf.low=Stereo.Proj.Appendix2$lower*100,
  conf.high=Stereo.Proj.Appendix2$upper*100,
  number=c("006", "005", "004", "003", "002", "001"))

StereoProj.Appendix2DF

hline.fig4 <- data.frame(z = c(2.5,
                               4.5)) 

Fig.Appendix2.3 <- ggplot(data = StereoProj.Appendix2DF, 
               aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high),
                  color = c("#DC863B", "#899DA4", "#DC863B", "#899DA4", "#DC863B", "#899DA4"),
                  fill = c("#DC863B", "#899DA4", "#DC863B", "#899DA4", "#DC863B", "#899DA4")) +
  theme_minimal() +
  #ggtitle("Do citizens StereoProj.Appendix2type Muslim politicians?") + 
  ylab("Views on LGB rights:\n+\nPolitician's religion:\n\n") + 
  xlab("% that answered 'don't know' (marginal means)") + 
  xlim(-10, 100) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Who answered 'don't know'?\nAnd for which politicians did they do so?") + 
  theme(plot.title.position = "plot") +
  geom_hline(linetype = "dotted", 
             aes(yintercept = z), 
             hline.fig4)
Fig.Appendix2.3

StereoProj.Appendix2DF.tab <- StereoProj.Appendix2DF %>% gt() %>%
  tab_header(title = md(" ")) %>%
  cols_align(align = "left") %>%
  tab_options(heading.align = "left") %>%
  tab_source_note(source_note = "") %>% 
  fmt_number(
    columns = 2:4,
    decimals = 2)
StereoProj.Appendix2DF.tab

#-------------------------------------------------------------------------------------------#
#--- Appendix3 Do those who answer middle middle middle on LGB rights not know as often? ---# 
#-------------------------------------------------------------------------------------------#

#-------------------------------------------------#
#--- Fig.Appendix3 3 Marginal Means Projection ---#
#-------------------------------------------------#

#projection
#symmetrical approach
FGNl <- FGNl %>% mutate(homoco.may.adopt.as.factor2 = case_when(homoco.may.adopt == 0 ~ "Anti",
                                                               #homoco.may.adopt == 0.1 ~ "Anti",
                                                               #homoco.may.adopt == 0.2 ~ "Anti",
                                                               #homoco.may.adopt == 0.3 ~ "Anti",
                                                               #homoco.may.adopt == 0.4 ~ "Anti",
                                                               homoco.may.adopt == 0.5 ~ "Middle",
                                                               #homoco.may.adopt == 0.6 ~ "Pro",
                                                               #homoco.may.adopt == 0.7 ~ "Pro",
                                                               #homoco.may.adopt == 0.8 ~ "Pro",
                                                               #homoco.may.adopt == 0.9 ~ "Pro",
                                                               homoco.may.adopt == 1 ~ "Pro"))
FGNl$homoco.may.adopt.as.factor2 <- as.factor(FGNl$homoco.may.adopt.as.factor2)

Proj.Appendix3 <- mm(FGNl, homoco.may.adopt.exp.dk ~ homoco.may.adopt.as.factor2,
           id = ~ INTNR, h0 = 0.5, weights = ~ w8)
Proj.Appendix3

Proj.Appendix3DF <- data.frame(
  names=c("Anti", "Middle", "Pro"),
  estimate=Proj.Appendix3$estimate*100,
  conf.low=Proj.Appendix3$lower*100,
  conf.high=Proj.Appendix3$upper*100,
  number=c("003", "002", "001"))

Proj.Appendix3DF

Fig.Appendix33 <- ggplot(data = Proj.Appendix3DF, 
               aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high),
                  color = c("#5BBCD6", "#F98400", "#00A08A"),
                  fill = c("#5BBCD6", "#F98400", "#00A08A")) +
  theme_minimal() +
  #ggtitle("Do citizens Projtype Muslim politicians?") + 
  ylab("Views on LGB rights:\n\n") + 
  xlab("% that expects politician to be pro-LGB rights (marginal means)") + 
  xlim(0, 100) +
  geom_vline(xintercept = 50) + 
  labs(subtitle = "Anti answered 0. Middle answered 5. Pro answered 10. \nThose who answered 1,2,3,4,6,7,8,9 were excluded",
    #caption = "This is the caption",
    title = "Do voters who don't know what they stand for (i.e. who answered 5 on a scale \nfrom 0 to 10) also answer 'don't know' when asked what they expect of a politician?") + 
  theme(plot.title.position = "plot")
Fig.Appendix33

Proj.Appendix3DF.tab <- Proj.Appendix3DF %>% gt() %>%
  tab_header(title = md(" ")) %>%
  cols_align(align = "left") %>%
  tab_options(heading.align = "left") %>%
  tab_source_note(source_note = "") %>% 
  fmt_number(
    columns = 2:4,
    decimals = 2)
Proj.Appendix3DF.tab

#---------------------------------------------------#
#--- Fig.Appendix2 4 Projection AND Stereotyping ---#
#---------------------------------------------------#

#Stereotyping AND Proj.Appendix2ection
FGNl$Stereo.Proj.Appendix2 <- 
  interaction(FGNl$Politician.Religion, FGNl$homoco.may.adopt.as.factor2, sep = "+")
Stereo.Proj.Appendix2 <- mm(FGNl, homoco.may.adopt.exp.dk ~ Stereo.Proj.Appendix2,
                  id = ~ INTNR, h0 = 0.5, weights = ~ w8)
Stereo.Proj.Appendix2


StereoProj.Appendix2DF <- data.frame(
  names=c("Anti + Muslim", "Anti + non-religious", 
          "Middle + Muslim", "Middle + non-religious",
          "Pro + Muslim", "Pro + non-religious"),
  estimate=Stereo.Proj.Appendix2$estimate*100,
  conf.low=Stereo.Proj.Appendix2$lower*100,
  conf.high=Stereo.Proj.Appendix2$upper*100,
  number=c("006", "005", "004", "003", "002", "001"))

StereoProj.Appendix2DF

hline.Fig.Appendix24 <- data.frame(z = c(2.5,
                               4.5)) 

Fig.Appendix24 <- ggplot(data = StereoProj.Appendix2DF, 
               aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high),
                  color = c("#DC863B", "#899DA4", "#DC863B", "#899DA4", "#DC863B", "#899DA4"),
                  fill = c("#DC863B", "#899DA4", "#DC863B", "#899DA4", "#DC863B", "#899DA4")) +
  theme_minimal() +
  #ggtitle("Do citizens StereoProjtype Muslim politicians?") + 
  ylab("Views on LGB rights:\n+\nPolitician's religion:\n\n") + 
  xlab("% that expects politician to be pro-LGB rights (marginal means)") + 
  xlim(-10, 100) +
  geom_vline(xintercept = 50) + 
  labs(subtitle = "Anti answered 0. Middle answered 5. Pro answered 10. \nThose who answered 1,2,3,4,6,7,8,9 were excluded",
    #caption = "This is the caption",
    title = "Do voters who don't know what they stand for (i.e. who answered 5 on a scale \nfrom 0 to 10) also answer 'don't know' more when asked what they expect of Muslim or \nnon-religious politicians?") + 
  theme(plot.title.position = "plot") +
  geom_hline(linetype = "dotted", 
             aes(yintercept = z), 
             hline.Fig.Appendix24)
Fig.Appendix24

StereoProj.Appendix2DF.tab <- StereoProj.Appendix2DF %>% gt() %>%
  tab_header(title = md(" ")) %>%
  cols_align(align = "left") %>%
  tab_options(heading.align = "left") %>%
  tab_source_note(source_note = "") %>% 
  fmt_number(
    columns = 2:4,
    decimals = 2)
StereoProj.Appendix2DF.tab

#--------------------------------------------------------------------------------------------#
#--- Appendix4 Do those who answer middle middle middle on LGB rights not know as often? ---# 
#--------------------------------------------------------------------------------------------#

#-------------------------------------------------#
#--- Fig.Appendix4 3 Marginal Means Projection ---#
#-------------------------------------------------#

#projection
#symmetrical approach
FGNl <- FGNl %>% mutate(homoco.may.adopt.as.factor3 = case_when(homoco.may.adopt == 0 ~ "Anti",
                                                               homoco.may.adopt == 0.1 ~ "Anti",
                                                               homoco.may.adopt == 0.2 ~ "Anti",
                                                               homoco.may.adopt == 0.3 ~ "Anti",
                                                               homoco.may.adopt == 0.4 ~ "Anti",
                                                               homoco.may.adopt == 0.5 ~ "Middle",
                                                               homoco.may.adopt == 0.6 ~ "Pro",
                                                               homoco.may.adopt == 0.7 ~ "Pro",
                                                               homoco.may.adopt == 0.8 ~ "Pro",
                                                               homoco.may.adopt == 0.9 ~ "Pro",
                                                               homoco.may.adopt == 1 ~ "Pro"))
FGNl$homoco.may.adopt.as.factor3 <- as.factor(FGNl$homoco.may.adopt.as.factor3)

Proj.Appendix4 <- mm(FGNl, homoco.may.adopt.exp.dk ~ homoco.may.adopt.as.factor3,
           id = ~ INTNR, h0 = 0.5, weights = ~ w8)
Proj.Appendix4

Proj.Appendix4DF <- data.frame(
  names=c("Anti", "Middle", "Pro"),
  estimate=Proj.Appendix4$estimate*100,
  conf.low=Proj.Appendix4$lower*100,
  conf.high=Proj.Appendix4$upper*100,
  number=c("003", "002", "001"))

Fig.Appendix43 <- ggplot(data = Proj.Appendix4DF, 
                         aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high),
                  color = c("#5BBCD6", "#F98400", "#00A08A"),
                  fill = c("#5BBCD6", "#F98400", "#00A08A")) +
  theme_minimal() +
  #ggtitle("Do citizens Projtype Muslim politicians?") + 
  ylab("Views on LGB rights:\n\n") + 
  xlab("% that expects politician to be pro-LGB rights (marginal means)") + 
  xlim(0, 100) +
  geom_vline(xintercept = 50) + 
  labs(subtitle = "Anti answered 0,1,2,3,4. Middle answered 5. Pro answered 6,7,8,9,10",
       #caption = "This is the caption",
       title = "Do voters project their views onto politicians?") + 
  theme(plot.title.position = "plot")
Fig.Appendix43

Proj.Appendix4DF.tab <- Proj.Appendix4DF %>% gt() %>%
  tab_header(title = md(" ")) %>%
  cols_align(align = "left") %>%
  tab_options(heading.align = "left") %>%
  tab_source_note(source_note = "") %>% 
  fmt_number(
    columns = 2:4,
    decimals = 2)
Proj.Appendix4DF.tab

#---------------------------------------------------#
#--- Fig.Appendix4 4 Projection AND Stereotyping ---#
#---------------------------------------------------#

#Stereotyping AND projection
FGNl$Stereo.Proj.Appendix4 <- 
  interaction(FGNl$Politician.Religion, FGNl$homoco.may.adopt.as.factor3, sep = "+")
Stereo.Proj.Appendix4 <- mm(FGNl, homoco.may.adopt.exp.dk ~ Stereo.Proj.Appendix4,
                  id = ~ INTNR, h0 = 0.5, weights = ~ w8)
Stereo.Proj.Appendix4


StereoProj.Appendix4DF <- data.frame(
  names=c("Anti + Muslim", "Anti + non-religious", 
          "Middle + Muslim", "Middle + non-religious",
          "Pro + Muslim", "Pro + non-religious"),
  estimate=Stereo.Proj.Appendix4$estimate*100,
  conf.low=Stereo.Proj.Appendix4$lower*100,
  conf.high=Stereo.Proj.Appendix4$upper*100,
  number=c("006", "005", "004", "003", "002", "001"))

StereoProj.Appendix4DF

hline.Fig.Appendix44 <- data.frame(z = c(2.5,
                                         4.5)) 

Fig.Appendix44 <- ggplot(data = StereoProj.Appendix4DF, 
                         aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high),
                  color = c("#DC863B", "#899DA4", "#DC863B", "#899DA4", "#DC863B", "#899DA4"),
                  fill = c("#DC863B", "#899DA4", "#DC863B", "#899DA4", "#DC863B", "#899DA4")) +
  theme_minimal() +
  #ggtitle("Do citizens StereoProjtype Muslim politicians?") + 
  ylab("Views on LGB rights:\n+\nPolitician's religion:\n\n") + 
  xlab("% that expects politician to be pro-LGB rights (marginal means)") + 
  xlim(-10, 100) +
  geom_vline(xintercept = 50) + 
  labs(subtitle = "Anti answered 0,1,2,3,4. Middle answered 5. Pro answered 6,7,8,9, 10",
       #caption = "This is the caption",
       title = "Do voters stereotype or project?") + 
  theme(plot.title.position = "plot") +
  geom_hline(linetype = "dotted", 
             aes(yintercept = z), 
             hline.Fig.Appendix44)
Fig.Appendix44

StereoProj.Appendix4DF.tab <- StereoProj.Appendix4DF %>% gt() %>%
  tab_header(title = md(" ")) %>%
  cols_align(align = "left") %>%
  tab_options(heading.align = "left") %>%
  tab_source_note(source_note = "") %>% 
  fmt_number(
    columns = 2:4,
    decimals = 2)
StereoProj.Appendix4DF.tab

#---------------------------------------------------#
#--- Appendix5 What about Christian politicians? ---#
#---------------------------------------------------#

#------------------------------------------#
#--- fig A1 Marginal Means Stereotyping ---#
#------------------------------------------#

FGNl <- FGNl %>% mutate(Politician.Religion = case_when(prof.exp.Mu == 1 ~ "Muslim politician",
                                                        prof.exp.Chr == 1 ~ "Christian politician",
                                                        prof.exp.No == 1 ~ "non-religious politician")) 
FGNl$Politician.Religion <- as.factor(FGNl$Politician.Religion)

Stereo.Appendix5 <- mm(FGNl, homoco.may.adopt.exp.01 ~ Politician.Religion,
                       id = ~ INTNR, h0 = 0.5, weights = ~ w8)
Stereo.Appendix5

Stereo.Appendix5DF <- data.frame(
  names=c("Christian", "Muslim", "non-religious"),
  estimate=Stereo.Appendix5$estimate*100,
  conf.low=Stereo.Appendix5$lower*100,
  conf.high=Stereo.Appendix5$upper*100,
  number=c("003", "002", "001"))

Stereo.Appendix5DF

Fig.Appendix5.1 <- ggplot(data = Stereo.Appendix5DF, 
                          aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high),
                  color = c("#DC863B", "#DC863B", "#899DA4"),
                  fill = c("#DC863B", "#DC863B", "#899DA4")) +
  theme_minimal() +
  #ggtitle("Do citizens Stereo.Appendix5type Muslim politicians?") + 
  ylab("Politician's religion:\n\n") + 
  xlab("% that expects politician to be pro-LGB rights (marginal means)") + 
  xlim(0, 100) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Do voters stereotype Muslim and Christian politicians?") + 
  theme(plot.title.position = "plot")
Fig.Appendix5.1

Stereo.Appendix5DF.tab <- Stereo.Appendix5DF %>% gt() %>%
  tab_header(title = md(" ")) %>%
  cols_align(align = "left") %>%
  tab_options(heading.align = "left") %>%
  tab_source_note(source_note = "") %>% 
  fmt_number(
    columns = 2:4,
    decimals = 2)
Stereo.Appendix5DF.tab

#------------------------------------------#
#--- Appendix6 comparing FR DE NL again ---#
#------------------------------------------#

#--------------#
#--- FRANCE ---#
#--------------#

#merge
#FGN <- rbind(eFR, eDE, eNL)

#pivot
#FGN <- zap_labels(FGN)
eFRl <- eFR %>%
  pivot_longer(
    c(-INTNR,
      -cntry,
      
      -MigBckGrnd,
      
      -binidrel2,
      -relMus,
      -relChr,
      -relOth,
      -relNon,
      
      -Female,
      -Education,
      -Age,
      -AGE2,
      -w8,
      
      -equal.pay.by.law,
      -homoco.may.adopt),
    names_to = c(".value", "profile"),
    names_sep = "_",
    values_drop_na = F)

#----------------------------------------#
#--- fig 1 Histogram statement homoco ---#
#----------------------------------------#
eFRl <- eFRl %>% mutate(homoco.may.adopt010 = case_when(homoco.may.adopt == 0 ~ 0,
                                                        homoco.may.adopt == 0.1 ~ 1,
                                                        homoco.may.adopt == 0.2 ~ 1,
                                                        homoco.may.adopt == 0.3 ~ 3,
                                                        homoco.may.adopt == 0.4 ~ 4,
                                                        homoco.may.adopt == 0.5 ~ 5,
                                                        homoco.may.adopt == 0.6 ~ 6,
                                                        homoco.may.adopt == 0.7 ~ 7,
                                                        homoco.may.adopt == 0.8 ~ 8,
                                                        homoco.may.adopt == 0.9 ~ 9,
                                                        homoco.may.adopt == 1 ~ 10)) 

Fig1.Appendix6.eFRl <- ggplot(eFRl, aes(x = factor(homoco.may.adopt010), 
                                  weight = w8,
                                  label = scales::percent(prop.table(stat(count))))) + 
  theme_minimal() +
  ylab(" ") + 
  xlab("Fully disagree                                                                                                                  Fully agree ") +
  geom_bar(aes(y = (..count..)/sum(..count..)), 
           fill = 'steelblue',
           position = "dodge") +
  labs(#subtitle = "Histogram",
    #caption = "This is the caption",
    title = "France: \nHistogram of responses to 'homosexual couples are allowed to adopt children'") + 
  scale_y_continuous(labels = scales::percent_format(accuracy = 1L)) + 
  theme(plot.title.position = "plot") + 
  geom_text(aes(y = ((..count..)/sum(..count..)), label = scales::percent((..count..)/sum(..count..))), stat = "count", vjust = -0.25) 
Fig1.Appendix6.eFRl

#-----------------------------------------#
#--- fig 2 Marginal Means Stereotyping ---#
#-----------------------------------------#

#Marginal Means
#politician profile
#Stereotyping
eFRl <- eFRl %>% mutate(Politician.Religion = case_when(prof.exp.Mu == 1 ~ "Muslim politician",
                                                        #prof.exp.Chr == 1 ~ "Christian",
                                                        prof.exp.No == 1 ~ "non-religious politician")) 
eFRl$Politician.Religion <- as.factor(eFRl$Politician.Religion)

#marginal means
Stereo.Appendix6.eFRl <- mm(eFRl, homoco.may.adopt.exp.01 ~ Politician.Religion,
             id = ~ INTNR, h0 = 0.5, weights = ~ w8)
Stereo.Appendix6.eFRl

Stereo.Appendix6.eFRl.DF <- data.frame(
  names=c("Muslim", "non-religious"),
  estimate=Stereo.Appendix6.eFRl$estimate*100,
  conf.low=Stereo.Appendix6.eFRl$lower*100,
  conf.high=Stereo.Appendix6.eFRl$upper*100,
  number=c("002", "001"))

Stereo.Appendix6.eFRl.DF

Fig2.Appendix6.eFRl <- ggplot(data = Stereo.Appendix6.eFRl.DF, 
               aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high),
                  color = c("#DC863B", "#899DA4"),
                  fill = c("#DC863B", "#899DA4")) +
  theme_minimal() +
  #ggtitle("Do citizens stereotype Muslim politicians?") + 
  ylab("Politician's religion:\n\n") + 
  xlab("% that expects politician to be pro-LGB rights (marginal means)") + 
  xlim(0, 100) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "France:  \nDo voters stereotype Muslim politicians?") + 
  theme(plot.title.position = "plot")
Fig2.Appendix6.eFRl

Stereo.Appendix6.eFRl.DF.tab <- Stereo.Appendix6.eFRl.DF %>% gt() %>%
  tab_header(title = md(" ")) %>%
  cols_align(align = "left") %>%
  tab_options(heading.align = "left") %>%
  tab_source_note(source_note = "") %>% 
  fmt_number(
    columns = 2:4,
    decimals = 2)
Stereo.Appendix6.eFRl.DF.tab

#---------------------------------------#
#--- fig 3 Marginal Means Projection ---#
#---------------------------------------#

#projection
#symmetrical approach
eFRl <- eFRl %>% mutate(homoco.may.adopt.as.factor = case_when(homoco.may.adopt == 0 ~ "Anti",
                                                               homoco.may.adopt == 0.1 ~ "Middle",
                                                               homoco.may.adopt == 0.2 ~ "Middle",
                                                               homoco.may.adopt == 0.3 ~ "Middle",
                                                               homoco.may.adopt == 0.4 ~ "Middle",
                                                               homoco.may.adopt == 0.5 ~ "Middle",
                                                               homoco.may.adopt == 0.6 ~ "Middle",
                                                               homoco.may.adopt == 0.7 ~ "Middle",
                                                               homoco.may.adopt == 0.8 ~ "Middle",
                                                               homoco.may.adopt == 0.9 ~ "Middle",
                                                               homoco.may.adopt == 1 ~ "Pro"))
eFRl$homoco.may.adopt.as.factor <- as.factor(eFRl$homoco.may.adopt.as.factor)

Proj.Appendix6.eFRl <- mm(eFRl, homoco.may.adopt.exp.01 ~ homoco.may.adopt.as.factor,
           id = ~ INTNR, h0 = 0.5, weights = ~ w8)
Proj.Appendix6.eFRl

ProjDF.Appendix6.eFRl <- data.frame(
  names=c("Anti", "Middle", "Pro"),
  estimate=Proj.Appendix6.eFRl$estimate*100,
  conf.low=Proj.Appendix6.eFRl$lower*100,
  conf.high=Proj.Appendix6.eFRl$upper*100,
  number=c("003", "002", "001"))

ProjDF.Appendix6.eFRl

Fig3.Appendix6.eFRl <- ggplot(data = ProjDF.Appendix6.eFRl, 
               aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high),
                  color = c("#5BBCD6", "#F98400", "#00A08A"),
                  fill = c("#5BBCD6", "#F98400", "#00A08A")) +
  theme_minimal() +
  #ggtitle("Do citizens Projtype Muslim politicians?") + 
  ylab("Views on LGB rights:\n\n") + 
  xlab("% that expects politician to be pro-LGB rights (marginal means)") + 
  xlim(-10, 100) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "France:  \nDo voters project their views onto politicians?") + 
  theme(plot.title.position = "plot")
Fig3.Appendix6.eFRl

ProjDF.Appendix6.eFRl.tab <- ProjDF.Appendix6.eFRl %>% gt() %>%
  tab_header(title = md(" ")) %>%
  cols_align(align = "left") %>%
  tab_options(heading.align = "left") %>%
  tab_source_note(source_note = "") %>% 
  fmt_number(
    columns = 2:4,
    decimals = 2)
ProjDF.Appendix6.eFRl.tab

#-----------------------------------------#
#--- fig 4 Projection AND Stereotyping ---#
#-----------------------------------------#

#Stereotyping AND projection
eFRl$Stereo.Proj.Appendix6.eFRl <- 
  interaction(eFRl$Politician.Religion, eFRl$homoco.may.adopt.as.factor, sep = "+")
Stereo.Proj.Appendix6.eFRl <- mm(eFRl, homoco.may.adopt.exp.01 ~ Stereo.Proj.Appendix6.eFRl,
                  id = ~ INTNR, h0 = 0.5, weights = ~ w8)
Stereo.Proj.Appendix6.eFRl

StereoProjDF.Appendix6.eFRl <- data.frame(
  names=c("Anti + Muslim", "Anti + non-religious", 
          "Middle + Muslim", "Middle + non-religious",
          "Pro + Muslim", "Pro + non-religious"),
  estimate=Stereo.Proj.Appendix6.eFRl$estimate*100,
  conf.low=Stereo.Proj.Appendix6.eFRl$lower*100,
  conf.high=Stereo.Proj.Appendix6.eFRl$upper*100,
  number=c("006", "005", "004", "003", "002", "001"))

StereoProjDF.Appendix6.eFRl

hline.fig4 <- data.frame(z = c(2.5,
                               4.5)) 

Fig4.Appendix6.eFRl <- ggplot(data = StereoProjDF.Appendix6.eFRl, 
               aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high),
                  color = c("#DC863B", "#899DA4", "#DC863B", "#899DA4", "#DC863B", "#899DA4"),
                  fill = c("#DC863B", "#899DA4", "#DC863B", "#899DA4", "#DC863B", "#899DA4")) +
  theme_minimal() +
  #ggtitle("Do citizens StereoProjtype Muslim politicians?") + 
  ylab("Views on LGB rights:\n+\nPolitician's religion:\n\n") + 
  xlab("% that expects politician to be pro-LGB rights (marginal means)") + 
  xlim(-30, 130) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "France: \nDo voters stereotype or project?") + 
  theme(plot.title.position = "plot") +
  geom_hline(linetype = "dotted", 
             aes(yintercept = z), 
             hline.fig4)
Fig4.Appendix6.eFRl

StereoProjDF.Appendix6.eFRl.tab <- StereoProjDF.Appendix6.eFRl %>% gt() %>%
  tab_header(title = md(" ")) %>%
  cols_align(align = "left") %>%
  tab_options(heading.align = "left") %>%
  tab_source_note(source_note = "") %>% 
  fmt_number(
    columns = 2:4,
    decimals = 2)
StereoProjDF.Appendix6.eFRl.tab

#---------------#
#--- Germany ---#
#---------------#

#merge
#FGN <- rbind(eFR, eDE, eNL)

#pivot
#FGN <- zap_labels(FGN)
eDEl <- eDE %>%
  pivot_longer(
    c(-INTNR,
      -cntry,
      
      -MigBckGrnd,
      
      -binidrel2,
      -relMus,
      -relChr,
      -relOth,
      -relNon,
      
      -Female,
      -Education,
      -Age,
      -AGE2,
      -w8,
      
      -equal.pay.by.law,
      -homoco.may.adopt),
    names_to = c(".value", "profile"),
    names_sep = "_",
    values_drop_na = F)

#----------------------------------------#
#--- fig 1 Histogram statement homoco ---#
#----------------------------------------#
eDEl <- eDEl %>% mutate(homoco.may.adopt010 = case_when(homoco.may.adopt == 0 ~ 0,
                                                        homoco.may.adopt == 0.1 ~ 1,
                                                        homoco.may.adopt == 0.2 ~ 1,
                                                        homoco.may.adopt == 0.3 ~ 3,
                                                        homoco.may.adopt == 0.4 ~ 4,
                                                        homoco.may.adopt == 0.5 ~ 5,
                                                        homoco.may.adopt == 0.6 ~ 6,
                                                        homoco.may.adopt == 0.7 ~ 7,
                                                        homoco.may.adopt == 0.8 ~ 8,
                                                        homoco.may.adopt == 0.9 ~ 9,
                                                        homoco.may.adopt == 1 ~ 10)) 

Fig1.Appendix6.eDEl <- ggplot(eDEl, aes(x = factor(homoco.may.adopt010), 
                                        weight = w8,
                                        label = scales::percent(prop.table(stat(count))))) + 
  theme_minimal() +
  ylab(" ") + 
  xlab("Fully disagree                                                                                                                  Fully agree ") +
  geom_bar(aes(y = (..count..)/sum(..count..)), 
           fill = 'steelblue',
           position = "dodge") +
  labs(#subtitle = "Histogram",
    #caption = "This is the caption",
    title = "Germany: \nHistogram of responses to 'homosexual couples are allowed to adopt children'") + 
  scale_y_continuous(labels = scales::percent_format(accuracy = 1L)) + 
  theme(plot.title.position = "plot") + 
  geom_text(aes(y = ((..count..)/sum(..count..)), label = scales::percent((..count..)/sum(..count..))), stat = "count", vjust = -0.25) 
Fig1.Appendix6.eDEl

Stereo.Appendix2DF.tab <- Stereo.Appendix2DF %>% gt() %>%
  tab_header(title = md(" ")) %>%
  cols_align(align = "left") %>%
  tab_options(heading.align = "left") %>%
  tab_source_note(source_note = "") %>% 
  fmt_number(
    columns = 2:4,
    decimals = 2)
Stereo.Appendix2DF.tab

#-----------------------------------------#
#--- fig 2 Marginal Means Stereotyping ---#
#-----------------------------------------#

#Marginal Means
#politician profile
#Stereotyping
eDEl <- eDEl %>% mutate(Politician.Religion = case_when(prof.exp.Mu == 1 ~ "Muslim politician",
                                                        #prof.exp.Chr == 1 ~ "Christian",
                                                        prof.exp.No == 1 ~ "non-religious politician")) 
eDEl$Politician.Religion <- as.factor(eDEl$Politician.Religion)

#marginal means
Stereo.Appendix6.eDEl <- mm(eDEl, homoco.may.adopt.exp.01 ~ Politician.Religion,
                            id = ~ INTNR, h0 = 0.5, weights = ~ w8)
Stereo.Appendix6.eDEl

Stereo.Appendix6.eDEl.DF <- data.frame(
  names=c("Muslim", "non-religious"),
  estimate=Stereo.Appendix6.eDEl$estimate*100,
  conf.low=Stereo.Appendix6.eDEl$lower*100,
  conf.high=Stereo.Appendix6.eDEl$upper*100,
  number=c("002", "001"))

Stereo.Appendix6.eDEl.DF

Fig2.Appendix6.eDEl <- ggplot(data = Stereo.Appendix6.eDEl.DF, 
                              aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high),
                  color = c("#DC863B", "#899DA4"),
                  fill = c("#DC863B", "#899DA4")) +
  theme_minimal() +
  #ggtitle("Do citizens stereotype Muslim politicians?") + 
  ylab("Politician's religion:\n\n") + 
  xlab("% that expects politician to be pro-LGB rights (marginal means)") + 
  xlim(0, 100) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Germany:  \nDo voters stereotype Muslim politicians?") + 
  theme(plot.title.position = "plot")
Fig2.Appendix6.eDEl

Stereo.Appendix6.eDEl.DF.tab <- Stereo.Appendix6.eDEl.DF %>% gt() %>%
  tab_header(title = md(" ")) %>%
  cols_align(align = "left") %>%
  tab_options(heading.align = "left") %>%
  tab_source_note(source_note = "") %>% 
  fmt_number(
    columns = 2:4,
    decimals = 2)
Stereo.Appendix6.eDEl.DF.tab

#---------------------------------------#
#--- fig 3 Marginal Means Projection ---#
#---------------------------------------#

#projection
#symmetrical approach
eDEl <- eDEl %>% mutate(homoco.may.adopt.as.factor = case_when(homoco.may.adopt == 0 ~ "Anti",
                                                               homoco.may.adopt == 0.1 ~ "Middle",
                                                               homoco.may.adopt == 0.2 ~ "Middle",
                                                               homoco.may.adopt == 0.3 ~ "Middle",
                                                               homoco.may.adopt == 0.4 ~ "Middle",
                                                               homoco.may.adopt == 0.5 ~ "Middle",
                                                               homoco.may.adopt == 0.6 ~ "Middle",
                                                               homoco.may.adopt == 0.7 ~ "Middle",
                                                               homoco.may.adopt == 0.8 ~ "Middle",
                                                               homoco.may.adopt == 0.9 ~ "Middle",
                                                               homoco.may.adopt == 1 ~ "Pro"))
eDEl$homoco.may.adopt.as.factor <- as.factor(eDEl$homoco.may.adopt.as.factor)

Proj.Appendix6.eDEl <- mm(eDEl, homoco.may.adopt.exp.01 ~ homoco.may.adopt.as.factor,
                          id = ~ INTNR, h0 = 0.5, weights = ~ w8)
Proj.Appendix6.eDEl

ProjDF.Appendix6.eDEl <- data.frame(
  names=c("Anti", "Middle", "Pro"),
  estimate=Proj.Appendix6.eDEl$estimate*100,
  conf.low=Proj.Appendix6.eDEl$lower*100,
  conf.high=Proj.Appendix6.eDEl$upper*100,
  number=c("003", "002", "001"))

ProjDF.Appendix6.eDEl

Fig3.Appendix6.eDEl <- ggplot(data = ProjDF.Appendix6.eDEl, 
                              aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high),
                  color = c("#5BBCD6", "#F98400", "#00A08A"),
                  fill = c("#5BBCD6", "#F98400", "#00A08A")) +
  theme_minimal() +
  #ggtitle("Do citizens Projtype Muslim politicians?") + 
  ylab("Views on LGB rights:\n\n") + 
  xlab("% that expects politician to be pro-LGB rights (marginal means)") + 
  xlim(-10, 100) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Germany:  \nDo voters project their views onto politicians?") + 
  theme(plot.title.position = "plot")
Fig3.Appendix6.eDEl 

ProjDF.Appendix6.eDEl.tab <- ProjDF.Appendix6.eDEl %>% gt() %>%
  tab_header(title = md(" ")) %>%
  cols_align(align = "left") %>%
  tab_options(heading.align = "left") %>%
  tab_source_note(source_note = "") %>% 
  fmt_number(
    columns = 2:4,
    decimals = 2)
ProjDF.Appendix6.eDEl.tab

#-----------------------------------------#
#--- fig 4 Projection AND Stereotyping ---#
#-----------------------------------------#

#Stereotyping AND projection
eDEl$Stereo.Proj.Appendix6.eDEl <- 
  interaction(eDEl$Politician.Religion, eDEl$homoco.may.adopt.as.factor, sep = "+")
Stereo.Proj.Appendix6.eDEl <- mm(eDEl, homoco.may.adopt.exp.01 ~ Stereo.Proj.Appendix6.eDEl,
                                 id = ~ INTNR, h0 = 0.5, weights = ~ w8)
Stereo.Proj.Appendix6.eDEl

StereoProjDF.Appendix6.eDEl <- data.frame(
  names=c("Anti + Muslim", "Anti + non-religious", 
          "Middle + Muslim", "Middle + non-religious",
          "Pro + Muslim", "Pro + non-religious"),
  estimate=Stereo.Proj.Appendix6.eDEl$estimate*100,
  conf.low=Stereo.Proj.Appendix6.eDEl$lower*100,
  conf.high=Stereo.Proj.Appendix6.eDEl$upper*100,
  number=c("006", "005", "004", "003", "002", "001"))

StereoProjDF.Appendix6.eDEl

hline.fig4 <- data.frame(z = c(2.5,
                               4.5)) 

Fig4.Appendix6.eDEl <- ggplot(data = StereoProjDF.Appendix6.eDEl, 
                              aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high),
                  color = c("#DC863B", "#899DA4", "#DC863B", "#899DA4", "#DC863B", "#899DA4"),
                  fill = c("#DC863B", "#899DA4", "#DC863B", "#899DA4", "#DC863B", "#899DA4")) +
  theme_minimal() +
  #ggtitle("Do citizens StereoProjtype Muslim politicians?") + 
  ylab("Views on LGB rights:\n+\nPolitician's religion:\n\n") + 
  xlab("% that expects politician to be pro-LGB rights (marginal means)") + 
  xlim(-30, 130) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "Germany: \nDo voters stereotype or project?") + 
  theme(plot.title.position = "plot") +
  geom_hline(linetype = "dotted", 
             aes(yintercept = z), 
             hline.fig4)
Fig4.Appendix6.eDEl

StereoProjDF.Appendix6.eDEl.tab <- StereoProjDF.Appendix6.eDEl %>% gt() %>%
  tab_header(title = md(" ")) %>%
  cols_align(align = "left") %>%
  tab_options(heading.align = "left") %>%
  tab_source_note(source_note = "") %>% 
  fmt_number(
    columns = 2:4,
    decimals = 2)
StereoProjDF.Appendix6.eDEl.tab

#-----------------------#
#--- The Netherlands ---#
#-----------------------#

#merge
#FGN <- rbind(eFR, eDE, eNL)

#pivot
#FGN <- zap_labels(FGN)
eNLl <- eNL %>%
  pivot_longer(
    c(-INTNR,
      -cntry,
      
      -MigBckGrnd,
      
      -binidrel2,
      -relMus,
      -relChr,
      -relOth,
      -relNon,
      
      -Female,
      -Education,
      -Age,
      -AGE2,
      -w8,
      
      -equal.pay.by.law,
      -homoco.may.adopt),
    names_to = c(".value", "profile"),
    names_sep = "_",
    values_drop_na = F)

#----------------------------------------#
#--- fig 1 Histogram statement homoco ---#
#----------------------------------------#
eNLl <- eNLl %>% mutate(homoco.may.adopt010 = case_when(homoco.may.adopt == 0 ~ 0,
                                                        homoco.may.adopt == 0.1 ~ 1,
                                                        homoco.may.adopt == 0.2 ~ 1,
                                                        homoco.may.adopt == 0.3 ~ 3,
                                                        homoco.may.adopt == 0.4 ~ 4,
                                                        homoco.may.adopt == 0.5 ~ 5,
                                                        homoco.may.adopt == 0.6 ~ 6,
                                                        homoco.may.adopt == 0.7 ~ 7,
                                                        homoco.may.adopt == 0.8 ~ 8,
                                                        homoco.may.adopt == 0.9 ~ 9,
                                                        homoco.may.adopt == 1 ~ 10)) 

Fig1.Appendix6.eNLl <- ggplot(eNLl, aes(x = factor(homoco.may.adopt010), 
                                        weight = w8,
                                        label = scales::percent(prop.table(stat(count))))) + 
  theme_minimal() +
  ylab(" ") + 
  xlab("Fully disagree                                                                                                                  Fully agree ") +
  geom_bar(aes(y = (..count..)/sum(..count..)), 
           fill = 'steelblue',
           position = "dodge") +
  labs(#subtitle = "Histogram",
    #caption = "This is the caption",
    title = "The Netherlands: \nHistogram of responses to 'homosexual couples are allowed to adopt children'") + 
  scale_y_continuous(labels = scales::percent_format(accuracy = 1L)) + 
  theme(plot.title.position = "plot") + 
  geom_text(aes(y = ((..count..)/sum(..count..)), label = scales::percent((..count..)/sum(..count..))), stat = "count", vjust = -0.25) 
Fig1.Appendix6.eNLl

#-----------------------------------------#
#--- fig 2 Marginal Means Stereotyping ---#
#-----------------------------------------#

#Marginal Means
#politician profile
#Stereotyping
eNLl <- eNLl %>% mutate(Politician.Religion = case_when(prof.exp.Mu == 1 ~ "Muslim politician",
                                                        #prof.exp.Chr == 1 ~ "Christian",
                                                        prof.exp.No == 1 ~ "non-religious politician")) 
eNLl$Politician.Religion <- as.factor(eNLl$Politician.Religion)

#marginal means
Stereo.Appendix6.eNLl <- mm(eNLl, homoco.may.adopt.exp.01 ~ Politician.Religion,
                            id = ~ INTNR, h0 = 0.5, weights = ~ w8)
Stereo.Appendix6.eNLl

Stereo.Appendix6.eNLl.DF <- data.frame(
  names=c("Muslim", "non-religious"),
  estimate=Stereo.Appendix6.eNLl$estimate*100,
  conf.low=Stereo.Appendix6.eNLl$lower*100,
  conf.high=Stereo.Appendix6.eNLl$upper*100,
  number=c("002", "001"))

Stereo.Appendix6.eNLl.DF

Fig2.Appendix6.eNLl <- ggplot(data = Stereo.Appendix6.eNLl.DF, 
                              aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high),
                  color = c("#DC863B", "#899DA4"),
                  fill = c("#DC863B", "#899DA4")) +
  theme_minimal() +
  #ggtitle("Do citizens stereotype Muslim politicians?") + 
  ylab("Politician's religion:\n\n") + 
  xlab("% that expects politician to be pro-LGB rights (marginal means)") + 
  xlim(-10, 100) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "The Netherlands:  \nDo voters stereotype Muslim politicians?") + 
  theme(plot.title.position = "plot")
Fig2.Appendix6.eNLl

Stereo.Appendix6.eNLl.DF.tab <- Stereo.Appendix6.eNLl.DF %>% gt() %>%
  tab_header(title = md(" ")) %>%
  cols_align(align = "left") %>%
  tab_options(heading.align = "left") %>%
  tab_source_note(source_note = "") %>% 
  fmt_number(
    columns = 2:4,
    decimals = 2)
Stereo.Appendix6.eNLl.DF.tab

#---------------------------------------#
#--- fig 3 Marginal Means Projection ---#
#---------------------------------------#

#projection
#symmetrical approach
eNLl <- eNLl %>% mutate(homoco.may.adopt.as.factor = case_when(homoco.may.adopt == 0 ~ "Anti",
                                                               homoco.may.adopt == 0.1 ~ "Middle",
                                                               homoco.may.adopt == 0.2 ~ "Middle",
                                                               homoco.may.adopt == 0.3 ~ "Middle",
                                                               homoco.may.adopt == 0.4 ~ "Middle",
                                                               homoco.may.adopt == 0.5 ~ "Middle",
                                                               homoco.may.adopt == 0.6 ~ "Middle",
                                                               homoco.may.adopt == 0.7 ~ "Middle",
                                                               homoco.may.adopt == 0.8 ~ "Middle",
                                                               homoco.may.adopt == 0.9 ~ "Middle",
                                                               homoco.may.adopt == 1 ~ "Pro"))
eNLl$homoco.may.adopt.as.factor <- as.factor(eNLl$homoco.may.adopt.as.factor)

Proj.Appendix6.eNLl <- mm(eNLl, homoco.may.adopt.exp.01 ~ homoco.may.adopt.as.factor,
                          id = ~ INTNR, h0 = 0.5, weights = ~ w8)
Proj.Appendix6.eNLl

ProjDF.Appendix6.eNLl <- data.frame(
  names=c("Anti", "Middle", "Pro"),
  estimate=Proj.Appendix6.eNLl$estimate*100,
  conf.low=Proj.Appendix6.eNLl$lower*100,
  conf.high=Proj.Appendix6.eNLl$upper*100,
  number=c("003", "002", "001"))

ProjDF.Appendix6.eNLl

Fig3.Appendix6.eNLl <- ggplot(data = ProjDF.Appendix6.eNLl, 
                              aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high),
                  color = c("#5BBCD6", "#F98400", "#00A08A"),
                  fill = c("#5BBCD6", "#F98400", "#00A08A")) +
  theme_minimal() +
  #ggtitle("Do citizens Projtype Muslim politicians?") + 
  ylab("Views on LGB rights:\n\n") + 
  xlab("% that expects politician to be pro-LGB rights (marginal means)") + 
  xlim(-10, 100) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "The Netherlands:  \nDo voters project their views onto politicians?") + 
  theme(plot.title.position = "plot")
Fig3.Appendix6.eNLl

ProjDF.Appendix6.eNLl.tab <- ProjDF.Appendix6.eNLl %>% gt() %>%
  tab_header(title = md(" ")) %>%
  cols_align(align = "left") %>%
  tab_options(heading.align = "left") %>%
  tab_source_note(source_note = "") %>% 
  fmt_number(
    columns = 2:4,
    decimals = 2)
ProjDF.Appendix6.eNLl.tab

#-----------------------------------------#
#--- fig 4 Projection AND Stereotyping ---#
#-----------------------------------------#

#Stereotyping AND projection
eNLl$Stereo.Proj.Appendix6.eNLl <- 
  interaction(eNLl$Politician.Religion, eNLl$homoco.may.adopt.as.factor, sep = "+")
Stereo.Proj.Appendix6.eNLl <- mm(eNLl, homoco.may.adopt.exp.01 ~ Stereo.Proj.Appendix6.eNLl,
                                 id = ~ INTNR, h0 = 0.5, weights = ~ w8)
Stereo.Proj.Appendix6.eNLl

StereoProjDF.Appendix6.eNLl <- data.frame(
  names=c("Anti + Muslim", "Anti + non-religious", 
          "Middle + Muslim", "Middle + non-religious",
          "Pro + Muslim", "Pro + non-religious"),
  estimate=Stereo.Proj.Appendix6.eNLl$estimate*100,
  conf.low=Stereo.Proj.Appendix6.eNLl$lower*100,
  conf.high=Stereo.Proj.Appendix6.eNLl$upper*100,
  number=c("006", "005", "004", "003", "002", "001"))

StereoProjDF.Appendix6.eNLl

hline.fig4 <- data.frame(z = c(2.5,
                               4.5)) 

Fig4.Appendix6.eNLl <- ggplot(data = StereoProjDF.Appendix6.eNLl, 
                              aes(x = estimate, y = reorder(names,desc(number)) )) +
  geom_pointrange(aes(xmin = conf.low, xmax = conf.high),
                  color = c("#DC863B", "#899DA4", "#DC863B", "#899DA4", "#DC863B", "#899DA4"),
                  fill = c("#DC863B", "#899DA4", "#DC863B", "#899DA4", "#DC863B", "#899DA4")) +
  theme_minimal() +
  #ggtitle("Do citizens StereoProjtype Muslim politicians?") + 
  ylab("Views on LGB rights:\n+\nPolitician's religion:\n\n") + 
  xlab("% that expects politician to be pro-LGB rights (marginal means)") + 
  xlim(-30, 130) +
  geom_vline(xintercept = 50) + 
  labs(#subtitle = "Subtitle of the plot",
    #caption = "This is the caption",
    title = "The Netherlands: \nDo voters stereotype or project?") + 
  theme(plot.title.position = "plot") +
  geom_hline(linetype = "dotted", 
             aes(yintercept = z), 
             hline.fig4)
Fig4.Appendix6.eNLl

StereoProjDF.Appendix6.eNLl.tab <- StereoProjDF.Appendix6.eNLl %>% gt() %>%
  tab_header(title = md(" ")) %>%
  cols_align(align = "left") %>%
  tab_options(heading.align = "left") %>%
  tab_source_note(source_note = "") %>% 
  fmt_number(
    columns = 2:4,
    decimals = 2)
StereoProjDF.Appendix6.eNLl.tab